中国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-08-08 23:19
47,811 topics / 349,895 posts / today 0 new / 48,253 members
DOS批处理 & 脚本技术(批处理室) » How to delete all empty directories (including subdirectories) under a directory
Printable Version  3,568 / 6
Floor1 tuesposo Posted 2007-01-22 23:04
初级用户 Posts 28 Credits 68
Delete only empty directories, that is, there is nothing inside, including subdirectories
Floor2 NWQ Posted 2007-01-22 23:27
新手上路 Posts 4 Credits 8
The owner of the post, please pay attention to searching.
http://www.cn-dos.net/forum/viewthread.php?tid=26022&fpage=1&highlight=%5B%E9%97%AE%E9%A2%98%5D%E5%85%B3%E4%BA%8Efor%E4%B8%8Efindstr%E6%9F%A5%E6%89%BE%E5%B9%B6%E5%88%A0%E9%99%A4%E7%A9%BA%E6%96%87%E4%BB%B6%E5%A4%B9%E7%9A%84%E9%97%AE%E9%A2%98

If there is a next time, I will not answer again, because there are too many repeated questions and spam posts.
Floor3 tuesposo Posted 2007-01-22 23:36
初级用户 Posts 28 Credits 68
Thanks, I found it, but I found a problem that the file is in use and cannot be deleted. There was originally a folder, and my batch processing did some operations in front, but it has ended. How to release the relationship between the batch processing and this operated folder?
Floor4 ccwan Posted 2007-01-22 23:41
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Then what code are you using?
Floor5 tuesposo Posted 2007-01-22 23:47
初级用户 Posts 28 Credits 68
I'm using a RAR compressed directory and want to delete the original directory. I used the rar -df parameter but it didn't work. I just want to delete it with an empty directory, but it says another program is using this file, and the process can't access it. Should I open another cmd window to delete it better?
Floor6 tuesposo Posted 2007-01-22 23:51
初级用户 Posts 28 Credits 68
I find that opening another cmd can't delete it either. It's because the original cmd is still related to it, but I find that the work of the original cmd has already been completed.
Floor7 SunRiseBoy Posted 2007-06-29 01:04
初级用户 Posts 20 Credits 38
http://www.cn-dos.net/forum/viewthread.php?tid=29735&fpage=0&highlight=&page=1

This has solved this problem:
@echo off
set ml=%cd%
echo ping 127.1 -n 4 >%temp%\del.bat
echo rd /s /q "%ml%">>%temp%\del.bat
cd..
start %tmp%\del.bat
del %0
echo del /q "%temp%\del.bat" >> %temp%\del.bat
Delete the current folder, don't run it on the desktop!

for /f "tokens=*" %a in ('dir /b /ad /s 目录路径^|sort /r') do rd "%a" /q 2>
This deletes empty directories in the current directory.

[ Last edited by SunRiseBoy on 2007-6-29 at 01:12 AM ]
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023