How do you loop in a Windows batch file?

Pradeep picture Pradeep · Aug 31, 2009 · Viewed 613.5k times · Source

What is the syntax for a FOR loop in a Windows batch file?

Answer

vancoeverden picture vancoeverden · Aug 22, 2010

If you want to do something x times, you can do this:

Example (x = 200):

FOR /L %%A IN (1,1,200) DO (
  ECHO %%A
)

1,1,200 means:

  • Start = 1
  • Increment per step = 1
  • End = 200