FOR - Looping commands - Windows CMD — by SS64.com
Reference for the FOR loop in CMD batch files, which repeats a command for each item in a list, file, folder set, number range or command output. It notes loop variables need a single letter, that variables only expand at loop start unless delayed expansion is used, and gives a short example creating 26 folders.
Quick steps
- Example: FOR %%G IN (a,b,c) DO (md C:\demo\%%G)
Paraphrased from the source. Menus can differ by version, so check the original for full details.
Source: FOR - Looping commands - Windows CMD by SS64.com. Licence: Link only (©).
- Source reviewed
- 2026-11-02
- Link checked
- 2026-11-02
- Tested hands-on
- Not by Oddbyte.Me