How to run a command with two variables change? One is incremented and the other is a variable determined by some path.
The problem is that the command does not allow to load multiple path in one command. I have over 10 folders for each check and I have to generate an unique filename incremented for each command for it is not overwritten by the next command.
Here an example might be more understandable but it does not work because there does not increment and thus it overwrites the previous file.
@echo off
SET "basename=file"
SET /a outname=0
:genloop
SET /a outname+=1
IF EXIST "%basename%-%outname%.csv" GOTO genloop
SET "outname=%basename%-%outname%.csv"
command.exe /out %outname% /LoadDirectory "C:\Dir-EXAMPLE-1"
command.exe /out %outname% /LoadDirectory "C:\Dir-EXAMPLE-ABC"
command.exe /out %outname% /LoadDirectory "C:\Dir-EXAMPLE-XYZ"
command.exe /out %outname% /LoadDirectory "C:\Dir-EXAMPLE-ETC"
The issue is related to this one How to create a unique output filename for Windows Script?
How can I do this in a simple and elegant way?
Thanks in advance.
Edit
Thanks to @MC ND & @ths, both solutions work perfectly and especially because you were very helpful and attentive. I do not know if it is possible to approve the two solutions, but if I have to make a choice I w'll chose the second option because it is closest to the question about the two variables and is well commented. I do not forget @Magoo because I appreciated his encouragement, thanks.
PS: Given my questions, the script is perfect as is, but maybe in the near future I will ask a new question related to it to make it more sophisticated in some scenarios. (in the possibilities of script interpreter)
PPS: Sorry for other people if my question was not very clear and concise. Feel free to modify the content and tags to make it more intelligible.
outnamein each case? Go on - go absolutely mad! Ask for something ourageous if you like. Perhapsfile.anumber.csvwould be all that can be achieved - but if we don't know what your heart's desire is, we aren't even going to attempt to grant your wish. Do you want the files generated in the nominated directory?