1

This could also be read "Why can't I get the for command work in my batch file."

When I try using the command:

FOR /F "tokens=1-4 delims=/ " %%a in ('something cool') DO something else cool %%a %%b %%c

It doesn't work! I'm getting:

%%a was unexpected at this time

Nixphoe
  • 4,584
  • 7
  • 34
  • 52

1 Answers1

4

The reason for this is that you need a single % when you're doing this in the command prompt and a double %% when you're doing it from a batch file.

Example Command Line:

FOR /F "tokens=1-4 delims=/ " %a in ('something cool') DO something else cool %a %b %c

Example Batch File:

FOR /F "tokens=1-4 delims=/ " %%a in ('something cool') DO something else cool %%a %%b %%c
Nixphoe
  • 4,584
  • 7
  • 34
  • 52