Learn about Chevy's new hybrid from AutoblogGreen!
AOL Tech

Automatically delete empty subdirectories with one-line batch file

rdempty.bat batch fileDeleting empty subdirectories seems like something Windows ought to do automatically, but for some reason that function just isn't included as part of the OS. Luckily, you don't need to download a utility to do it; instead, you can create a single line batch file that will do exactly what you're looking for:

for /f "usebackq" %%d in ("dir /ad/b/s | sort /R") do rd "%%d"

Raymond Chen, the venerable Microsoft coder, explains how this works. Basically, it uses a trick to enumerate the directories in reverse order. Since you can't delete a directory that contains data (including other directories) the only way to automate deleting directories is to start at the very bottom of the tree and work your way up.

Related Headlines

Reader Comments (Page 1 of 1)

Download Squad Features

View Posts By

Categories
Audio (873)
Beta (363)
Blogging (713)
Browsers (83)
Business (1386)
Design (833)
Developer (945)
E-mail (532)
Finance (129)
Fun (1816)
Games (581)
Internet (5008)
Kids (140)
Office (511)
OS Updates (594)
P2P (185)
Photo (477)
Podcasting (169)
Productivity (1374)
Search (291)
Security (554)
Social Software (1149)
Text (443)
Troubleshooting (53)
Utilities (2030)
Video (1065)
VoIP (141)
web 2.0 (826)
Web services (3438)
Companies
Adobe (189)
AOL (53)
Apache Foundation (1)
Apple (486)
Canonical (36)
Google (1353)
IBM (30)
Microsoft (1339)
Mozilla (481)
Novell (20)
OpenOffice.org (45)
PalmSource (12)
Red Hat (17)
Symantec (14)
Yahoo! (360)
License
Commercial (694)
Shareware (197)
Freeware (2097)
Open Source (944)
Misc
Podcasts (14)
Features (397)
Hardware (167)
News (1139)
Holiday Gift Guide (15)
Platforms
Web (0)
Mobile (0)
Windows (3759)
Windows Mobile (436)
BlackBerry (46)
Macintosh (2134)
iPhone (106)
Linux (1638)
Unix (79)
Palm (177)
Symbian (124)
Columns
Ask DLS (11)
Analysis (35)
Browser Tips (299)
DLS Podcast (6)
Googleholic (206)
How-Tos (105)
DLS Interviews (19)
Design Tips (15)
Mobile Minute (136)
Mods (68)
Time-Wasters (409)
Weekend Review (40)
Imaging Tips (32)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Sponsored Links

Advertise with Download Squad

Download Squad bloggers (30 days)

#BloggerPostsCmts
1Brad Linder8913
2Lee Mathews4966
3Jason Clarke191
4Christina Warren1816
5Christina Clark162
6Jay Hathaway103
7Lisa Hoover73
8Dolores Parker44
9Todd Ritter30
10Grant Robertson10

Most Commented On (60 days)

Recent Comments

Urlesque Headlines

BloggingStocks Tech Coverage

More Tech Coverage

Other Weblogs Inc. Network blogs you might be interested in: