evfwcqcg
evfwcqcg

Reputation: 16335

Loop for hidden folderes in Windows

How can I loop through all hidden folders, in windows-cmd?

This code

FOR /D %i IN (*) DO @echo %i 

handles only non-hidden folders.

Upvotes: 4

Views: 3138

Answers (1)

steenhulthin
steenhulthin

Reputation: 4773

To loop through all folder in a directory (including hidden folders) in cmd you can use:

FOR /F "tokens=*" %i IN ('DIR /A:D /b') do @echo %i

You can exclude system folder using:

FOR /F "tokens=*" %i IN ('DIR /A:D-S /b') do @echo %i

And if you want to get subfolders (you might not want to this in a folder with many subfolders) :

FOR /F "tokens=*" %i IN ('DIR /A:D /s /b') do @echo %i

Upvotes: 8

Related Questions