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-06-24 08:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Question] About the problem of finding and deleting empty folders with for and findstr View 7,584 Replies 22
Floor 16 Posted 2006-12-30 06:07 ·  中国 江苏 苏州 联通
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
The above sentence is used well, and I've learned it.
Floor 17 Posted 2007-01-03 22:19 ·  中国 广东 肇庆 四会市 电信
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
Thanks again to兄 namejm for the code...

Because I've been quite busy for the past week. When I have time to come online, I don't have time to test, so I simply haven't been coming...

I always feel uncomfortable if I don't play with new code...

I'll find time to replace the code in my batch script with兄's...

Let's see how it works.
Floor 18 Posted 2007-02-11 03:19 ·  中国 北京 鹏博士BGP
新手上路
Credits 4
Posts 2
Joined 2007-01-12 03:55
19-year member
UID 76237
Gender Male
Status Offline
```
dir d:\ /ad /b /s |sort /r >>d:\kill.txt

For /f %%i in (d:\kill.txt) DO rd %%i

echo y |del d:\kill.txt
```
Floor 19 Posted 2007-02-14 22:43 ·  中国 上海 徐汇区 电信
初级用户
Credits 54
Posts 26
Joined 2007-02-10 12:34
19-year member
UID 79167
Gender Male
Status Offline
The one on the second floor doesn't seem to work. I've tested it many times. I'm using XP SP2.
Floor 20 Posted 2007-07-08 21:52 ·  中国 福建 厦门 海沧区 电信
初级用户
Credits 74
Posts 37
Joined 2007-06-28 11:47
18-year member
UID 92573
Gender Male
Status Offline
Floor 21 Posted 2007-12-31 20:26 ·  中国 甘肃 兰州 电信
初级用户
Credits 114
Posts 8
Joined 2005-04-21 00:00
21-year member
UID 38448
Gender Male
Status Offline
It seems it doesn't work.

for /f "tokens=*" %a in ('dir /b /ad /s F:\Program Files\hygl\PIC\^|sort /r') do rd "%a" /q 2>nul


for /f "tokens=*" %a in ('dir /b /ad /s F:\Program Files\hygl\PIC^|sort /r') do rd "%a" /q 2>nul


Both of these have been tried.
Floor 22 Posted 2010-01-12 11:33 ·  中国 吉林 白山 联通
新手上路
Credits 15
Posts 7
Joined 2006-02-12 01:37
20-year member
UID 50218
Status Offline
In the command `rd "%a" /q 2>nul`, the `2` represents the standard error output (stderr). The `2>nul` part is a redirection operation that redirects the standard error output to the null device, which means that any error messages generated by the `rd` command will be suppressed and not displayed.
Floor 23 Posted 2010-01-12 15:08 ·  中国 湖北 武汉 教育网
新手上路
Credits 12
Posts 11
Joined 2009-11-28 17:39
16-year member
UID 155545
Gender Male
Status Offline
Little brother also comes one:

@echo off&for /r %a in (.) do (1>nul 2>nul dir /a-d /b /s "%a" || rd /s /q "%a")

Error marked by 2
Forum Jump: