Loop for hidden folderes in Windows

2019-05-10 23:33发布

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.

1条回答
做自己的国王
2楼-- · 2019-05-11 00:37

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
查看更多
登录 后发表回答