How to grab the names of all subfolders in a batch script?
4 answers
On Windows, you can use:
dir /ad /b
/ad
will only provide you with directories will /b
present it in "naked" format
EDIT (answer to comment):
If you want to iterate over these directories and do something with them, use the command for
:
for /F "delims=" %%a in ('dir /ad /b') do (
echo %%a
)
- note the double
%
is for package use, if you use for command line use one%
. - added resetting default space demits in response to @ Helen's comment
+7
source to share