How do you loop in a Windows batch file? - Stack Overflow Conditionally perform a command several times syntax-FOR-Files FOR %%parameter IN (set) DO command syntax-FOR-Files-Rooted at Path FOR R [[drive:]path] %%parameter IN (set) DO command syntax-FOR-Folders FOR D %%parameter IN (folder_set) DO command syntax-FOR-List of numbers FOR L %%parameter IN (start,step,end) DO command syntax-FOR-File contents FOR F ["options"] %%parameter IN