Wednesday, June 13, 2007
Poor man's array in cmd/batch scripts
::create the "array"
Set VarName1=Value1
Set VarName2=Value2
Set VarName3=Value3
::parse through the "array"
For /f "tokens=2 delims==" %%i in ('set Varname') do echo %%i
Set "VarName" output is every variable that starts with "VarName" as VarName1=Value1, etc… so you only want token 2 using the equal sign as a delimeter.
Set VarName1=Value1
Set VarName2=Value2
Set VarName3=Value3
::parse through the "array"
For /f "tokens=2 delims==" %%i in ('set Varname') do echo %%i
Set "VarName" output is every variable that starts with "VarName" as VarName1=Value1, etc… so you only want token 2 using the equal sign as a delimeter.
Labels: admin scripts, scripting
