I'm new to using batch files. I'm trying to run a program I've written several times with slightly different command line parameters. In order to do this, I've made two lists that hold the different parameters. I then want to iterate through both lists, but I'm getting really confused on how to get the items from my list in a loop. (Looking through batch tutorials and other threads hasn't helped).
My batch code is as follows:
set D=("airplanebase.xml","catfacebase.xml","churchbase.xml","coffee_cupbase.xml","hutbase.xml","maskbase.xml","pumpkinbase.xml","spacebase.xml")
set C=("186.svg","187.svg","188.svg","189.svg","190.svg","191.svg","192.svg","193.svg")
FOR /l %%A IN (0,1,7) DO (
CurvedNonogramsGenerator.exe file=%D[%%A]% outfile=%C[%%A]% -af -am cratio="0" outdir="\output\\" weights="1000,3,3,7,0" temp="1.001" pairits="0"
)
When I try to run it the echo says that it's calling my program like this:
CurvedNonogramsGenerator.exe file= outfile= -af -am cratio="0" outdir="C:\Users\DeMeessias\Documents\1. Studie\0.MasterThesis\output\\" weights="1000,3,3,7,0" temp="1.001" pairits="0"
It also gives an error that says the index is out of the bounds of the matrix. As you can see the two arguments that I'm trying to get from the lists are left blank.
I'm just really confused with how the % operator works I guess. I've also seen tutorials that use ! as an operator for getting stuff out of lists, but that doesnt seem to work either. It is treated as though the ! is just random text rather than an operator.
So how do I get it to correctly load in the arguments from the lists?
Edit: So following advice from comments I changed the batch file to:
set D[0]="airplanebase.xml"
set D[1]="catfacebase.xml"
set D[2]="churchbase.xml"
set D[3]="coffee_cupbase.xml"
set D[4]="hutbase.xml"
set D[5]="maskbase.xml"
set D[7]="pumpkinbase.xml"
set D[8]="spacebase.xml"
set C[0]="186.svg"
set C[1]="187.svg"
set C[2]="188.svg"
set C[3]="189.svg"
set C[4]="190.svg"
set C[5]="191.svg"
set C[6]="192.svg"
set C[7]="193.svg"
FOR /l %%A IN (0,1,7) DO (
CurvedNonogramsGenerator.exe file=!D[%%A]! outfile=!C[%%A]! -af -am cratio="0" outdir="C:\Users\DeMeessias\Documents\1. Studie\0.MasterThesis\output\\" weights="1000,3,3,7,0" temp="1.001" pairits="0"
)
But this doesnt solve the problem either... The echo now says that its calling my program like
CurvedNonogramsGenerator.exe file=!D[0]! outfile=!C[0]! -af -am cratio="0" outdir="C:\Users\DeMeessias\Documents\1. Studie\0.MasterThesis\output\\" weights="1000,3,3,7,0" temp="1.001" pairits="0"
Which gives the index out of bounds error again...
EDIT 2: Adding setlocal EnableDelayedExpansion to the top of the file fixed it! Thanks for the help everyone.