Skip to content

Batch Script For Loop through Directories

Learn how to use the /D flag in Windows batch scripts to loop through directories, with practical examples and explanations of directory traversal behavior.

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

for /D %y in (D:\documents\*) do @echo %y
Navigation