Please let us know how useful you find this tip by rating it below. Do you have a useful Windows tip, timesaver or workaround to share? Submit it to our monthly tip contest and you could win a prize!
Here's a familiar scenario: After doing extensive cleanup on a \Documents and Settings or \Applications directory, you're left with many empty folders but no way to selectively delete them. The command-line functions for removing directories are all or nothing; there's no way to selectively instruct them to remove only empty ones.
RMEMPTY runs as a command-line application. The only parameter that needs to be passed is the name of a directory or pathname, which RMEMPTY will inspect recursively for empty folders. Originally, the program didn't delete the specified directory itself if it was empty after all other processing was completed; it now does this.
To purge multiple folder hierarchies, simply pass multiple pathnames as parameters. For example, rmempty c:\folder1 c:\folder2. The files are never deleted, just the empty folders.
RMEMPTY has one drawback, although I suspect it will be fixed in future revisions: It does not delete empty directories with names that contain Unicode or non-ASCII characters. The source code is also not available, unfortunately, but Mr. Good can be reached at firstname.lastname@example.org if you want to drop suggestions about improvements.
Note: I've found that one useful but rather non-work-related application for this tool is cleaning up all the empty directories left behind in a My Music directory after consolidating and renaming many files. This was actually how I found out about the non-English pathname limitation!
Serdar Yegulalp is editor of the Windows Power Users Newsletter. Check it out for the latest advice and musings on the world of Windows network administrators -- and please share your thoughts as well!
This was first published in July 2005