![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-11 07:57 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Question: how to traverse subfolders and get each subfolder name one by one |
| Printable Version 1,007 / 9 |
| Floor1 lgs6715 | Posted 2009-02-02 11:09 |
| 新手上路 Posts 8 Credits 8 | |
|
cd /d d:\oabak
for /f "delims=" %%d in ('dir /ad /s /b /on') do (echo %%d) pause I've already managed to traverse the subfolders, but how do I extract the subfolder names? HELP |
|
| Floor2 slore | Posted 2009-02-02 11:21 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
for /? has it
echo %%~nd |
|
| Floor3 lgs6715 | Posted 2009-02-02 11:25 |
| 新手上路 Posts 8 Credits 8 | |
|
Thanks. Solved...
|
|
| Floor4 lgs6715 | Posted 2009-02-02 15:45 |
| 新手上路 Posts 8 Credits 8 | |
|
Question for everyone:
Right now I have a folder ALL, under it there are subfolders 1, 2, 3, 4, and under each of those there are many more subfolders. Now I only want to traverse subfolders 1, 2, 3, 4, and not traverse the subfolders under 1, 2, 3, 4. How do I do that? |
|
| Floor5 lgs6715 | Posted 2009-02-02 15:52 |
| 新手上路 Posts 8 Credits 8 | |
|
Question for everyone:
Right now I have a folder ALL, under it there are subfolders 1, 2, 3, 4, and under each of those there are many more subfolders. Now I only want to traverse subfolders 1, 2, 3, 4, and not traverse the subfolders under 1, 2, 3, 4. How do I do that? |
|
| Floor6 523066680 | Posted 2009-02-02 16:25 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
| Floor7 523066680 | Posted 2009-02-02 16:27 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
You're in trouble now You asked here and also made another post... Duplicated.
|
|
| Floor8 lgs6715 | Posted 2009-02-02 17:27 |
| 新手上路 Posts 8 Credits 8 | |
|
@echo on& setlocal enabledelayedexpansion
cd /d d:\all for /f "delims=" %%d in ('dir /ad /s /b /on %cd%') do ( set temp_subfolder=%%~nd @ECHO !temp_subfolder! ) PAUSE It listed folders 1, 2, 3, 4, but the subfolders under 1, 2, 3, 4 were also listed... |
|
| Floor9 523066680 | Posted 2009-02-02 18:32 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
Not sure about the situation, give this a try
|
|
| Floor10 yishanju | Posted 2009-02-02 18:36 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
If you add the /S parameter to dir, of course it will list all directories.
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |