// batch for loop
for /l %%x in (1, 1, 100) do (
echo %%x
copy %%x.txt z:whateveretc
)
for %%variable in (strings/numbers) do(
your code
)
for /f ["options"] %%variable in (filename) do (
your code
)
for /l ["options"] %%variable in (start_value, increment_by ,end_value) do (
your code
)
Here ["options"]:
delims=xxx The delimiter character(s). Default value = a space
eol=; Default value is ; .If the line starts with ;
it will be treated as comment and it will
not be printed in the output.
You can change the Default value to any other character.
tokens=n Specifies which numbered items to read from each line.
Default value is 1.
for /l %x in (1, 1, 100) do (
echo %x
copy %x.txt z:whateveretc
)
@echo off
:main
:: Put all your code here under the "main" sub-routine
echo EXECUTED MAIN
goto rerun_prompt
:rerun_prompt
ECHO Re-run the script? [Y/N]:
SET /p choice=
IF /I %choice% == Y goto main
IF /I %choice% == N (
echo Exiting...
EXIT
)
ECHO "%choice%" is not valid, try again
goto rerun_prompt
for /l %%x in (1, 1, 100) do (
echo %%x
)