I'm new to scripting in batch files. Currently trying to get the hang of for loops. I know how they should look like:
for /f %%i in (1, 1, 50) do (
echo %%i
)
So that will print everything between 1 and 50, but I would like to know how to put a variable in the for loop like:
max=50
for /f %%i in (1, 1, max) do (
echo %%i
)
But that just spits out an error. Does anyone have another way of doing it (that works)?
set "max=50"
for /f %%i in (1; 1; %max%) do (
echo %%i
)
try this.
Something along these lines...
@Echo Off
Set "max=50"
For /L %%A In (1,1,%max%) Do Echo %%A
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.