本帖最后由 tmplinshi 于 2011-3-31 13:26 编辑
- @echo off
- if exist "%~dp0\lock.txt" exit /b
- call :o "%~f0" >"%~dp0\lock.txt"
- exit /b
-
- :o
- pushd "%~dp1"
- echo %date% %time%
- echo,
- set "DestDir=d:\cont"
- set OutDir=
- set #dir_num#=1
- for %%i in (*.png) do (
- SetLocal EnableDelayedExpansion
- set OutDir_Pre=%DestDir%\%%~ni_cont\%%~ni_cont_
- if not exist "!OutDir_Pre!*" (
- set "OutDir=!OutDir_Pre!1"
- ) else (
- for /d %%D in ("!OutDir_Pre!*") do (
- set /a #dir_num# += 1, _%%~nxD = 0
- )
- for /l %%N in (1 1 !#dir_num#!) do (
- if not defined _%%~ni_cont_%%N (
- if not defined OutDir set OutDir=!OutDir_Pre!%%N
- )
- )
- )
- md "!OutDir!"
- copy "%%i" "!OutDir!\%%~ni_cont_!#dir_num#!.png" >nul
- echo !OutDir!\%%~ni_cont_!#dir_num#!.png
- EndLocal
- )
- POPD
- goto :eof
复制代码
|