Skip to main content

Batch Script For Loop through Files

For Loop through Files

To loop through files using the for loop, you must use % followed by a single letter, such as %a.

Example

An example of a for loop for looping through files at a given location.

for %a in (D:\documents\*) do @echo %a
note

This will go through all the files in documents folder of D: and display the files in output console.