1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/windows/for.md
2021-12-21 18:18:58 +05:30

830 B

for

Conditionally execute a command several times. More information: https://docs.microsoft.com/windows-server/administration/windows-commands/for.

  • Execute given commands for the specified set:

for %{{variable}} in ({{item_a item_b item_c}}) do ({{echo Loop is executed}})

  • Iterate over a given range of numbers:

for /l %{{variable}} in ({{from}}, {{step}}, {{to}}) do ({{echo Loop is executed}})

  • Iterate over a given list of files:

for %{{variable}} in ({{file_a.ext file_b.ext file_c.ext}}) do ({{echo Loop is executed}})

  • Iterate over a given list of directories:

for /d %{{variable}} in ({{directory_a/ directory_b/ directory_c/}}) do ({{echo Loop is executed}})

  • Perform a given command in every directory:

for /d %{{variable}} in (*) do (if exist %{{variable}} {{echo Loop is executed}})