Created
December 19, 2021 17:35
-
-
Save neps-in/d69d128c2d863f654ae980a9bddc8016 to your computer and use it in GitHub Desktop.
rdempty.cmd Delete empty directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for /f "usebackq" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanation :
https://devblogs.microsoft.com/oldnewthing/20080417-00/?p=22703
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.