Raymond Chen, the Microsoft coder, explains that you don’t need a whole 260KB program to automatically delete empty subdirectories. 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"
This is the long-forgotten follow-up to Performing an operation in each subdirectory of a directory tree from batch. We’re using the same technique as in that article, but pumping the result through “| sort /R” to reverse the order of the enumeration so we enumerate the directories bottom-up rather than top-down. This is important for deleting empty directories because you have to remove the subdirectories before you remove the parent.
Windows, Delete, Script, Tips

TrackBack URI Leave a comment »