batch copy a file multiple times while renaming?

Advanced Renamer forum
#1 : 22/04-20 14:01
Matthew James
Posts: 2
I have a recurring situation where I need to rename the same image file with 20 different (but similar names). Is there a way to copy and rename the same file multiple times all at once?

example: the file is named 'xx-ae-9a'

I want to create 20 variations of this file replacing the 'xx' with different values (that correspond to milestone birthdays) so:

18-ae-9a
21-ae-9a
30-ae-9a
40-ae-9a
etc for 50, 60, 65, 70, 75 etc

So I guess I'm asking if there's a way to multiple the same file and output it with different names in one batch.

Thanks

Matt



#2 : 22/04-20 15:26
David Lee
Posts: 1125
ARen will only rename files not make copies.

However you can do this using the Windows command line.

eg

FOR /F %A in (source.txt) DO copy ae-9a.ext %A-ae9a.ext

Here ae9a.ext is your original image file

source.txt is a text file containing your list of numbers - one per line

The command will loop though all the numbers in source.txt saving them in the variable %A and for each one it will copy ae-9a.ext to a new file, prefixing each one with "%A-".

You will finish up with the desired copies plus the original file.

I have assumed that you will run the command from a commmand console (cmd.exe) opened in the folder containing the files. If not you will have to specify the full paths of the files.

Note: if you use this in a batch file then you must replace %A with %%A

Edit: M$oft has tried to force you to use PowerShell instead of the command console - but unfortunately PowerShell does not support "FOR /F... " .

To open a command console in a specific folder shift+right-click on the folder name and select "Open PowerShell window here" - then type cmd.exe in the PowerShell window and enter.

edited: 22/04-20 15:36
#3 : 22/04-20 16:26
Matthew James
Posts: 2
Reply to #2:

David, I can't thank you enough for that! I had literally hundreds of these to do so you've saved me hours, if not days, of mind-numbing copying, pasting, and renaming manually. Really appreciate you taking the time to explain this alternative method - it's very kind of you.