I want to make a .bat to copy & rename a file multiple times. I want to have a list of names, and an original file, then I want to copy that file and rename it for each name on the list.
How I can do this using a .bat file?
Also is it possible to run winrar fromthe .bat to .rar or .zip every file after copying/renaming?
Example:
$file = "file.tmpl";
$names = "name1, name2, name3, nameetc";
foreach( $names as $name) {
copy $file; //to avoid deleting the original
rename $file to $name;
zip $name; //I dont really need this but if its easy to do i will like to use it
}
So I start with a file.tmpl and I end up with 4 more files (which are a duplicate of file.tmpl) called name1, name2, name3, nameetc.
The example is not a real coding lang, I used a sort of php sintax because is the language I know more.
Do the file names need to be in a string list?
If you can name them in a separate file, like so,
then this batch file will work
You would call it like this
In other words, I called the batch file
make-copies.bat, and the name filefilenames.txt, and I used it to copy a file calledmla-play.pdf.This also allows you to change the target name list without modifying the batch file.
Hope this helps.