Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows批量制作文件的多个副本_Windows_Batch File - Fatal编程技术网

Windows批量制作文件的多个副本

Windows批量制作文件的多个副本,windows,batch-file,Windows,Batch File,我正在尝试制作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 "out

我正在尝试制作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!"

)

这只是生成一个名为
的文件!文件名一遍又一遍。我做错了什么?

谢谢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!"

)

您没有启用延迟扩展。您可以尝试以下操作:
setlocal EnableDelayedExpansion
&
set“i=100000”
&
for/l%%A in(1,1726)do(
&
set/A i+=1
&
复制“2-original.jpg”!i:~1!\u 2%%~xA
&