|
Answer» I am having some issue with passing value and subsequently using them in a batch file. I have a batch file called Test.cmd. Test.cmd can be run as follows: Test /role /multi
In side the cmd, I check for /multi as follows: if /I "%1% == "-multi" shift&goto MultipleRole if /I "%1% == "/multi" shift&goto MultipleRole goto EndMultipleRole :MultipleRole set multipleFile =1 shift goto EndMultipleRole
Then later in the batch, I want to check the value in multipleFile use it to create files. If MultipleFile is 1, I want to pass the variable "FileName%d.txt" to another program (where the program will generate the files FileName1.txt, FileName2.txt, FileName3.txt, etc) The program will SUBSTITUTE the %d for numbers. But if MultipleFile is not 1, I just pass FileName.txt to the program WITHOUT the %d.
What's the BEST way to achieve this?
Thanks
Fidelis
Code: [Select]if /I .%1==.-multi shift&goto MultipleRole if /I .%1== ./multi shift&goto MultipleRole goto EndMultipleRole :MultipleRole set multipleFile =1 shift goto EndMultipleRole
There is no such parameter as %d. Either set it WITHIN your code (%d%) , or create it within a for loop (%%d). Note: only the FIRST eight characters of label names are used
Another note: Parameters created in one file and passed to a second file on the command line are renamed to %1, %2, %3 etc. This is also true on a call to a same file subroutine. Parameters passed thru the environment retain their original names.
|