0

When entering a command manually it works fine, but when using that same command in a batch file it errors out. HOW to fix it has already been answered here, but I am wondering WHY you have to change things.

The linked example is that when using a for statement in a batch file, the variables need two percent (%) signs instead of one.

On the cmd line:

for %f in folder move ...

From a batch file:

for %%f in folder move ...
Compo
  • 36,585
  • 5
  • 27
  • 39
J. Tate
  • 163
  • 1
  • 10
  • Have you gone thru [\[ this \]](https://stackoverflow.com/questions/14509652/what-is-the-difference-between-and-in-a-cmd-file) question? – sjsam Oct 25 '17 at 17:50
  • 1
    Because Microsoft says so. Open up a cmd prompt and type: `for /?` – Squashman Oct 25 '17 at 17:53
  • And you can read: [How does the Windows Command Interpreter (CMD.EXE) parse scripts?](https://stackoverflow.com/a/4095133/1417694) – Squashman Oct 25 '17 at 17:57

0 Answers0