我在一個檔案夾中有一些 pdf,我需要像這樣組織它們:
PDF名稱:123.12.123.pdf;102030_01.pdf;102030_02.pdf;123.4512.34561.23412.pdf
現在我需要使用檔案名創建檔案夾(不洗掉字符,例如:12345123456123412)并將它們重命名為以下模式:例如:P12345123456123412_V1_A0V0_T07-54-369-664_S00001.pdf
為此,我使用了以下代碼,效果很好:
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
If "%~1" == "" GoTo :EOF
For %%G In (%*) Do (For %%H In ("%%~G") Do If "%%~aH" Lss "-" (
Echo Error! %%G no longer exists.
%SystemRoot%\System32\timeout.exe /T 2 /NoBreak 1>NUL
) Else If "%%~aH" GEq "d" (For %%I In ("%%~G\*.pdf") Do Call :Sub "%%~I"
) Else If /I "%%~xG" == ".pdf" (Call :Sub "%%~G"
) Else (Echo Error! %%G is not a PDF
%SystemRoot%\System32\timeout.exe /T 2 /NoBreak 1>NUL))
GoTo :EOF
:Sub
Set "basename=%~n1"
Set "basename=
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/515750.html
標籤:批处理文件文件重命名
