I am trying to create a batch script which would perform the same action for each parameter given. For example, giving X files as parameters:
script.bat "file1.txt" "file2.txt" "file3.txt" "file4.txt" ... "fileX.txt"
will rename them to:
"file1.bin" "file2.bin" "file3.bin" "file4.bin" ... "fileX.bin"
Rename is just an example, I will need it for more complex operations too.
I guess it should be something like for each but I’m new in batch scripts.
I just wonder if I could just increment %1 index…
You can use
SHIFTto shift the parameters left. In other words calling shift will put the second parameter to %1, the third to %2 etc.So you need something like:
This will just print the arguments in order, but you can do whatever you want inside the loop.