Skip to main content
added 94 characters in body; added 2 characters in body
Source Link
Alvin Wong
  • 12.5k
  • 5
  • 55
  • 78

Because FOR /F loops every line of a text file, and when used with a string ("" quoted) it only do things on that line. It does delimit by whitespace, but that is to be used with the option tokens.

You should use FOR

set var=1 2 3

for %%i in (%var) do (
  echo %%i
)

If you want to loop numbers, use the following:

for /L %%i in (1,1,3) do (
  echo %%i
)

Because FOR /F loops every line of a text file, and when used with a string ("" quoted) it only do things on that line. It does delimit by whitespace, but that is to be used with the option tokens.

If you want to loop numbers, use the following:

for /L %%i in (1,1,3) do (
  echo %%i
)

Because FOR /F loops every line of a text file, and when used with a string ("" quoted) it only do things on that line. It does delimit by whitespace, but that is to be used with the option tokens.

You should use FOR

set var=1 2 3

for %%i in (%var) do (
  echo %%i
)

If you want to loop numbers, use the following:

for /L %%i in (1,1,3) do (
  echo %%i
)
Source Link
Alvin Wong
  • 12.5k
  • 5
  • 55
  • 78

Because FOR /F loops every line of a text file, and when used with a string ("" quoted) it only do things on that line. It does delimit by whitespace, but that is to be used with the option tokens.

If you want to loop numbers, use the following:

for /L %%i in (1,1,3) do (
  echo %%i
)