Find and remove files

Once you start using a Mac, you’ll find files like .DS_Store everywhere. There is however an easy way to find and remove these recursively from (you guessed it) the command line:

Here’s the command:

$ find . -type f -name ".DS_Store" -exec rm {} ;

What this says is find all files (of type f) called .DS_Store and execute the rm (remove) command on them.

Run from the top directory and it will recurse its way into all sub directories and remove the files. Obviously this is a dangerous command so use with a bit of caution.

Might be an idea to have the files go to Trash rather than deleted permanently 🙂