Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows batch file to make multiple copies of a single file, with each copy being assigned a unique filename

Tags:

batch-file

I'm experimenting with XCOPY and various switch commands, in attempting to create a Windows batch file for making multiple (a set number) copies of a single image file.

I'd like to : name the file to be copied; state the number of copies required; have each copy of the file assigned a unique filename. (eg original file 0001.png, with copies 0001-2.png, 0001-3.png, etc)

I'd greatly appreciate help with this, as my scripting knowledge is limited. Thank you.

like image 350
alhas2009 Avatar asked Aug 13 '14 18:08

alhas2009


1 Answers

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

See for /?

In a batch file use %%A rather than %A at the command prompt.

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)
like image 56
Noodles Avatar answered Dec 13 '22 18:12

Noodles