I need to write a batch file that received a directory that contains a huge number of empty sub-directories and deletes them all.
What's the fastest way of doing this? (by fast I mean not like what Windows Explorer does when you try to delete such a directory...)
Clarification:
I'm not trying to delete only empty directories. It just so happens that this dir I'm trying to delete is mostly empty sub-dirs.
To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r . Directories that are removed with the rmdir command cannot be recovered, nor can directories and their contents removed with the rm -r command.
Right-click the Shell (folder) key, select New, and click on Key. Name the key Quick Delete and press Enter.
del /f/s/q foldername is good too, but it leaves behind the directory structure. This is nearly three times faster than a single rmdir, based on time tests with a Windows XP encrypted disk, deleting ~30GB/1,000,000 files/15,000 folders: rmdir takes ~2.5 hours, del+rmdir takes ~53 minutes.
rd yourdirname /s/q
Will do the job regardless of whether they are empty or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With