cmd loop and output subfolder location
Can anyone tell me how to set up a .bat file that would do the following in windows:
let's say I have: c:\somefolder\ from which I run dostuff.bat which then prints the full addresses of the subfolders in c:\somefolder\
e.g.:
c:\somefolder\sub1\subsub1\
c:\somefolder\sub1\subsub2\
c:\somefolder\sub1\subsub3\
c:\somefolder\sub2\subsub1\开发者_如何学编程
...
...
It only needs to go two levels down, if that helps.
Thanks
KarlYou could use the FOR /D
command
for /D %%A in ("C:\temp\*") do (
echo %%A
for /D %%2 in ("%%~A\*") do echo --- %%~2
)
You can use a DOS port of the find
command:
find . -maxdepth 2 -type d
Download GNU utilities to get find.exe here.
I think, FOR
with the options /D
and /R path
should give you the desired output:
FOR /R "C:\temp" /D %%A IN (*) ECHO %%A
If you specifically wish the output to contain \
at the end, put it explicitly after %%A
:
... ECHO %%A\
精彩评论