- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir /b /a-d *.pdf^|find "#"') do (
- for /f "tokens=1 delims=#" %%b in ("%%a") do (
- if exist "%%~b.pdf" (
- set /a n=1
- call :No_DupFile "%%~b"
- ren "%%~a" "%%~b~!n!.pdf"
- ) else (
- ren "%%~a" "%%~b.pdf"
- )
- )
- )
- endlocal
- exit/b
- :No_DupFile
- if exist "%~1~!n!.pdf" (
- set /a n+=1
- goto :No_DupFile
- )
复制代码
|