中国DOS联盟论坛

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-11-20 10:10
47,820 topics / 349,938 posts / today 0 new / 48,297 members
DOS学习入门 & 精彩文章 (教学室)  Moderators: ko20010214、zzz19760225
View digest  4,336 threads / 174 pages
Subject Author Replies / Views Last post
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:\"`. winddeity 6 / 2,139 2004-03-13 00:00
willsort
What's different about the FOR here? xiaojun 7 / 882 2004-03-13 00:00
willsort
关于help命令? jjjjj162118 7 / 942 2004-03-13 00:00
Wengier
求救 !! zry369 5 / 748 2004-03-13 00:00
xinsl
win2000下用ghost 5959535 6 / 1,134 2004-03-13 00:00
全职悍匪
Question for experts about Ghost tiantian 1 / 766 2004-03-13 00:00
曾经
BIOS settings hqingyong 8 / 1,744 2004-03-12 00:00
小龙二代
请教[求助] 网球男子 2 / 704 2004-03-12 00:00
liliang
[求助]想学DOS在网上有什么入门的书看的吗? tsyyy 6 / 918 2004-03-12 00:00
lisan001
Methods of Using DOS 枯井无波 1 / 1,923 2004-03-12 00:00
doscommand
Is it possible to reinstall XP this way? mchotdog 1 / 816 2004-03-12 00:00
mchotdog
windows98下的MS-DOS与纯dos有什么区别 fanxin_bme 1 / 1,012 2004-03-12 00:00
Wengier
我的ghost2003为什么TCP/IP选项是灰色的? ev_huang 14 / 2,147 2004-03-11 00:00
贵州__瓦佐
[Help] Making onboard sound work qinqong 4 / 737 2004-03-11 00:00
txm723435
怎样学DOS 高兴就好 13 / 1,296 2004-03-11 00:00
wphs0326
有关chkdsk yahooabc2434 1 / 791 2004-03-11 00:00
xiaojun
如何在DOS6.X启动盘中安装光驱 lmxc602 1 / 686 2004-03-11 00:00
Wengier
How to change the AGP slot voltage qqqqllll 2 / 1,848 2004-03-10 00:00
枯井无波
请帮手解决疑问!多谢啦! razor 1 / 682 2004-03-10 00:00
Kinglion
【请帮助】dos3.28在虚拟机里的安装问题 ricepot100 2 / 756 2004-03-10 00:00
qzwqzw
请加我[求助] 酸酸细雨 1 / 717 2004-03-10 00:00
Kinglion
班主请进 一意孤行 3 / 844 2004-03-10 00:00
Wengier
[求助] a904qy 1 / 689 2004-03-10 00:00
doscommand
请教在XP系统下如何格式化C盘重装XP系统? 菜鸟一号 3 / 1,104 2004-03-10 00:00
doscommand
How to install Windows 98 using DOS pxd0714 11 / 2,361 2004-03-09 00:00
wphs0326
Prev  1 … 122 123 124 125 126 127 128 … 174  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023