China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-09-30 18:07
中国DOS联盟论坛 » DOS讨论区 » DOS学习入门 & 精彩文章 (教学室)
DOS学习入门 & 精彩文章 (教学室)Moderators: ko20010214、zzz19760225
大家可以在这儿学习、交流和分享关于DOS的入门和安装等方面的基础知识和经验,将新手培养成各类DOS高手,以实现共同推广和发展DOS。
View digest Search this forum 4,336 threads / 174 pages
Subject
Author
Replies
Views
Last post
New replies
Please enter the command to traverse all folders in the hard disk in .bat format. ```batch @echo off for /r "C:\" %%i in (.) do ( echo %%i ) ``` Above is a simple .bat script example. It uses the `for /r` command to recursively traverse all folders starting from the root directory of the C drive (you can change "C:\" to other drive letters as needed).在.bat中请教如何遍历硬盘中的所有文件夹 请输入以.bat格式遍历硬盘中所有文件夹的命令 ```batch @echo off for /r "C:\" %%i in (.) do ( echo %%i ) ``` 上面是一个简单的.bat脚本示例,它使用`for /r`命令从C盘根目录开始递归遍历所有文件夹(你可以根据需要将"C:\"改为其他盘符)Please enter the command to traverse all folders in the hard disk in .bat format. ```batch @echo off for /r "C:\" %%i in (.) do ( echo %%i ) ``` Above is a simple .bat script example. It uses the `for /r` command to recursively traverse all folders starting from the root directory of the C drive (you can change "C:\" to other drive letters as needed). ### 步骤解释: 1. `@echo off`:关闭命令回显,使脚本执行时不显示命令本身。 2. `for /r "C:\" %%i in (.) do (`:`for /r`表示递归遍历,后面的路径是起始路径,这里是C盘根目录,`%%i`是循环变量,`in (.)`表示遍历的对象是文件夹(`.`表示文件夹)。 3. `echo %%i`:输出当前遍历到的文件夹路径。 如果要遍历其他硬盘分区,比如D盘,只需要将`"C:\"`改为`"D:\"`即可。To ask how to traverse all folders in the hard disk in .bat, please enter the command in .bat format for traversing all folders in the hard disk. ```batch @echo off for /r "C:\" %%i in (.) do ( echo %%i ) ``` The above is a simple example of a .bat script. It uses the `for /r` command to recursively traverse all folders starting from the root directory of the C drive (you can change "C:\" to other drive letters as needed). ### Step explanation: 1. `@echo off`: Turns off command echoing, so that the command itself is not displayed when the script is executed. 2. `for /r "C:\" %%i in (.) do (`: `for /r` means recursive traversal, the following path is the starting path, here it is the root directory of the C drive, `%%i` is the loop variable, `in (.)` means the object to be traversed is a folder (`.` means a folder). 3. `echo %%i`: Outputs the path of the currently traversed folder. If you want to traverse other hard disk partitions, such as the D drive, you only need to change `"C:\"` to `"D:\"`.
6
2,049
2004-03-13 00:00
by willsort
New replies
7
821
2004-03-13 00:00
by Wengier
New replies
5
653
2004-03-13 00:00
by xinsl
New replies
6
1,035
2004-03-13 00:00
by 全职悍匪
New replies
8
1,617
2004-03-12 00:00
by 小龙二代
New replies
2
620
2004-03-12 00:00
by liliang
New replies
1
1,830
2004-03-12 00:00
by doscommand
热门 / New replies
13
1,201
2004-03-11 00:00
by wphs0326
New replies
1
694
2004-03-11 00:00
by xiaojun
New replies
1
620
2004-03-10 00:00
by Kinglion
New replies
3
730
2004-03-10 00:00
by Wengier
New replies
1
608
2004-03-10 00:00
by doscommand