[Shell] How to remove all empty directories in a sub-tree?
Using shell, both in Linux or in Windows Sub-system for Linux [WSL], you can remove all the empty directories in a folder or hard drive and in all the sub-folders.
open your terminal and navigate into the top directory from where you want to remove all the empty sub-directories, and then type.
I found the answer in https://unix.stackexchange.com/questions/8430/how-to-remove-all-empty-directories-in-a-subtree :
Combining GNU find options and predicates, this command should do the job:
find . -type d -empty -delete
-type drestricts to directories
-emptyrestricts to empty ones
-deleteremoves each directory The tree is walked from the leaves without the need to specify
-depthas it is implied by