我试图制作文件名递增的单个文件的726份副本,即00001_2.jpg
,00002_2.jpg
等:
for /l %%A in (1,1,726) do (
set /a i+=1
rem Add leading zeroes:
set FileName=00000!%%A!_2
rem Trim to only four digits, from the end
set FileName=!FileName:~-5!
rem Add "output_" and extension again
set FileName=!FileName!%%~xf
rem Rename the file
copy "2-original.jpg" "!FileName!"
)
这只是一遍又一遍地生成一个名为!FileName!
的文件。我做错了什么?
答案 0 :(得分:1)
感谢Squashman,这很有用
SETLOCAL ENABLEDELAYEDEXPANSION
for /l %%A in (1,1,726) do (
set /a i+=1
rem Add leading zeroes:
set FileName=000000%%A_2
rem Trim to only four digits, from the end
set FileName=!FileName:~-7!
rem Add "output_" and extension again
set FileName=!FileName!.jpg
rem Rename the file
copy "2-original.jpg" "!FileName!"
)