Cmd Easy · Lesson 1 · On the house

for loops in bat

Iterate files and tokens. Lesson 1 is free — on the house.

Lessons · Cmd Easy · Lesson 1 of 10 · On the house

for loops in bat

Iterate files and tokens.

Illustration for Cmd
Lesson 1 is on the house.

for %%F in (*.txt) do echo %%F loops files in a .bat (use %F interactively).

for /f parses command output or files into tokens.

Use delayed expansion when modifying vars inside blocks (next lessons deepen this).

Quote paths; spaces break naive loops.

Prefer robocopy/PowerShell for complex bulk work when batch loops get brittle.

for

for %F in (*.txt) do @echo %F
Match this when you type.

Quiz

In a .bat file, loop variables use?

Quiz

for /f is for?

Quiz

Interactive cmd for-loops use?

Check

Match the still for: for loops in bat.

Open-book: the answers are on this page. Pass every quiz and check (4) to mark the lesson done. This visit: 0/4.