[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 tmplinshi 于 2011-3-31 13:26 编辑
  1. @echo off
  2. if exist "%~dp0\lock.txt" exit /b
  3. call :o "%~f0" >"%~dp0\lock.txt"
  4. exit /b
  5. :o
  6. pushd "%~dp1"
  7. echo %date%    %time%
  8. echo,
  9. set "DestDir=d:\cont"
  10. set OutDir=
  11. set #dir_num#=1
  12. for %%i in (*.png) do (
  13.     SetLocal EnableDelayedExpansion
  14.     set OutDir_Pre=%DestDir%\%%~ni_cont\%%~ni_cont_
  15.     if not exist "!OutDir_Pre!*" (
  16.         set "OutDir=!OutDir_Pre!1"
  17.     ) else (
  18.         for /d %%D in ("!OutDir_Pre!*") do (
  19.            set /a #dir_num# += 1, _%%~nxD = 0
  20.         )
  21.         for /l %%N in (1 1 !#dir_num#!) do (
  22.             if not defined _%%~ni_cont_%%N (
  23.                  if not defined OutDir set OutDir=!OutDir_Pre!%%N
  24.             )
  25.         )
  26.     )
  27.     md "!OutDir!"
  28.     copy "%%i" "!OutDir!\%%~ni_cont_!#dir_num#!.png" >nul
  29.     echo !OutDir!\%%~ni_cont_!#dir_num#!.png
  30.     EndLocal
  31. )
  32. POPD
  33. goto :eof
复制代码
1

评分人数

TOP

8# linjuming


已修改

TOP

本帖最后由 tmplinshi 于 2011-4-3 23:02 编辑

13# linjuming
  1. @echo off
  2. if exist "%~dp0\lock.txt" exit /b
  3. call :o "%~f0" >"%~dp0\lock.txt"
  4. exit /b
  5. :o
  6. pushd "%~dp1"
  7. echo %date%    %time%
  8. echo,
  9. set "DestDir=d:\cont"
  10. set OutDir=
  11. set #dir_num#=1
  12. for /f "delims=" %%i in (' dir /a:-d /b /o:n *.png ') do (
  13.     SetLocal EnableDelayedExpansion
  14.     set fname_old=%%~ni
  15.     set "fname=!fname_old:.=<d>!"
  16.     for %%i in ("!fname:_=.!") do set fname=%%~ni
  17.     set fname=!fname:.=_!
  18.     set "fname=!fname:<d>=.!"
  19.     set OutDir_Pre=%DestDir%\!fname!_cont\!fname!_cont_
  20.     if not exist "!OutDir_Pre!*" (
  21.         set "OutDir=!OutDir_Pre!1"
  22.     ) else (
  23.         for /d %%D in ("!OutDir_Pre!*") do (
  24.            set /a #dir_num# += 1, _%%~nxD = 0
  25.         )
  26.         for /l %%N in (1 1 !#dir_num#!) do (
  27.             if not defined _!fname!_cont_%%N (
  28.                  if not defined OutDir set OutDir=!OutDir_Pre!%%N
  29.             )
  30.         )
  31.     )
  32.     md "!OutDir!"
  33.     copy "%%i" "!OutDir!\!fname!_cont_!#dir_num#!.png" >nul
  34.     echo !fname_old!.png -^> !OutDir!\!fname!_cont_!#dir_num#!.png
  35.     EndLocal
  36. )
  37. POPD
  38. goto :eof
复制代码

TOP

返回列表