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 05:12
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to delete all empty directories (including subdirectories) under a directory View 3,501 Replies 6
Original Poster Posted 2007-01-22 23:04 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
Delete only empty directories, that is, there is nothing inside, including subdirectories
Floor 2 Posted 2007-01-22 23:27 ·  中国 河北 廊坊 三河市 移动
新手上路
Credits 8
Posts 4
Joined 2007-01-21 20:57
19-year member
UID 77269
Gender Male
Status Offline
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.
相思相见知何日,此时此夜难为情
Floor 3 Posted 2007-01-22 23:36 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
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?
Floor 4 Posted 2007-01-22 23:41 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Then what code are you using?
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 5 Posted 2007-01-22 23:47 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
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?
Floor 6 Posted 2007-01-22 23:51 ·  中国 上海 上海乾万网络(QianWan_Network)有限公司(电信出口)
初级用户
Credits 68
Posts 28
Joined 2006-12-29 00:55
19-year member
UID 74861
Gender Male
Status Offline
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.
Floor 7 Posted 2007-06-29 01:04 ·  中国 湖北 十堰 郧西县 联通
初级用户
Credits 38
Posts 20
Joined 2006-07-04 16:50
19-year member
UID 58001
Status Offline
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 ]
Forum Jump: