Windows batch file to create multiple copies of a single file, with each copy being given a unique file name

I am experimenting with XCOPY and various switch commands, trying to create a Windows batch file to create multiple (given number) copies of a single image file.

I would like to: name the file you want to copy; indicate the number of copies required; Each copy of the file is assigned a unique file name. (e.g. source file 0001.png, with copies 0001-2.png, 0001-3.png, etc.)

I would really appreciate help on this, as my scripting skills are limited. Thanks.

+6
source share
1 answer
for /l %A in (1,1,100) do copy "C:\some folder\file.ext" "C:\some folder\file-%A.ext" 

See for /?

In the batch file, use %%A , not %A on the command line.

 FOR /L %variable IN (start,step,end) DO command [command-parameters] The set is a sequence of numbers from start to end, by step amount. So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would generate the sequence (5 4 3 2 1) 
+16
source

Source: https://habr.com/ru/post/973780/


All Articles