![]() |
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-09-23 02:43 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » [Question] About the problem of finding and deleting empty folders with for and findstr |
| Printable Version 8,240 / 22 |
| Floor16 NaturalJ0 | Posted 2006-12-30 06:07 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
The above sentence is used well, and I've learned it.
|
|
| Floor17 voiL | Posted 2007-01-03 22:19 |
| 中级用户 Posts 189 Credits 384 | |
|
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. |
|
| Floor18 lingxing1020 | Posted 2007-02-11 03:19 |
| 新手上路 Posts 2 Credits 4 | |
|
```
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 ``` |
|
| Floor19 pyjhhh | Posted 2007-02-14 22:43 |
| 初级用户 Posts 26 Credits 54 | |
|
The one on the second floor doesn't seem to work. I've tested it many times. I'm using XP SP2.
|
|
| Floor20 422904z | Posted 2007-07-08 21:52 |
| 初级用户 Posts 37 Credits 74 | |
| Floor21 lzymbz | Posted 2007-12-31 20:26 |
| 初级用户 Posts 8 Credits 114 | |
|
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. |
|
| Floor22 bsijl | Posted 2010-01-12 11:33 |
| 新手上路 Posts 7 Credits 15 | |
|
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.
|
|
| Floor23 fengwuxzg | Posted 2010-01-12 15:08 |
| 新手上路 Posts 11 Credits 12 | |
|
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 |
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |