Friday 26 August 2011

Recursively remove all empty directories

In Linux:
find <parent-dir> -type d -empty -delete
Alternatives:
find <parent-dir> -empty -type d -exec rmdir {} +
find <parent-dir> -depth -type d -empty -exec rmdir -v {} +
find <parent-dir> -depth -type d -empty -exec rmdir -v {} \;

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

Possibly Related Posts

No comments:

Post a Comment