I would like to delete all empty folders on an external disk. How can I do this?
First of all note that deleting empty directories usually isn't necessary. Some services or applications might even need certain directories to exist. Be aware of what you're doing.
You can list empty folders with
Now, if you want to delete whatever
Note: This will not ask for confirmation. It'll delete all the directories it can, i.e. the ones where you have permissions to delete. They will not be moved to the trash but gone forever. If you want to be asked before removal, change the command to something like the following:
I've made a small and free program that solves this better:
The advantage of this program is that it also finds folders that are apparently empty but contain the invisible ".DS_Store" file.
And it also lets you move the found items to Trash right away.