Windows Batch: How to create and use generated code
I need help creating a for loop that generates the following example code
below depending on the %count% variable and then execute it:
So if %count%=4 it would output the following:
IF %M%==1 set %variable%
IF %M%==2 set %variable%
IF %M%==3 set %variable%
IF %M%==4 EXIT
If %count%= 7 output would be:
IF %M%==1 set %variable%
IF %M%==2 set %variable%
IF %M%==3 set %variable%
IF %M%==4 set %variable%
IF %M%==5 set %variable%
IF %M%==6 set %variable%
IF %M%==7 EXIT
I was thinking of echoing the for loop into a new batch file and then
execute it, not sure if thats the best approach?
Ex:
for /l %%a in (1,1,%count%) do (
echo IF %M%==%count% set %variable% > new.bat
)
call new.bat
No comments:
Post a Comment