Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to delete all empty folders on an external disk. How can I do this?

share|improve this question
Found a simple way to do this:… – Vinod Jun 25 '13 at 9:37

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 find, when run from

find . -type d -empty

By default find lists files and folders, but here, -type d restricts it to directories, and the -empty option shows only empty directories. This will recurse all folders descending from your home directory (/Users/your-username/ or short, ~). To expand this to your entire filesystem, use:

find / -type d -empty

Here, / signifies the root of your Mac OS X file system. You can of course use any other starting point as well, for example your external disk mounted under /Volumes/your-disk-name;

find /Volumes/your-disk-name -type d -empty

Now, if you want to delete whatever find outputs, simply append -delete, like so:

find . -type d -empty -delete

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:

find . -type d -empty -exec rm -ri '{}' \;
share|improve this answer
It gives me output about illegal option -- t typeand empty seems to not be able to recognize. – AsTeR Mar 5 '13 at 12:38
@AsTeR The OS X version of find requires a path, so try again with find . -type d, not find -type d (the latter works for GNU find). – slhck Mar 5 '13 at 12:43
This is amazing. Thank you! – SimplGy Aug 26 '13 at 23:15
fantastic answer. thanks! – Macondo2Seattle Sep 14 '14 at 21:41
While this works, it probably doesn't locate folders that only contain the hidden .DS_Store files, making them technically non-empty but appearing empty to the user. If a user wants to find all folders that appear empty, those he once had opened in Finder won't be found this way because the Finder would have added a .DS_Store file. – SuperTempel Nov 4 '14 at 12:17

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.