Asepsis: Get rid of .DS_Store files on OS X

This tutorial lets you remove .DS_Store files on Mac safely, which are all over the place and mess with your project folders.

If you’ve been using Mac since a long time, you must have encountered ‘.DS_Store’ files sometime. These are hidden files which get created in Finder automatically, and you can find them in almost every folder on your Mac!

A ‘.DS_Store’ file contains preferences related to the folder and contains information like position of icons, view settings and etc. meta data. All this sounds fine, but if you’re a developer, you’ll surely hate this as these files get into your project folder.

Here’s how you can get rid of these hidden files.

No .DS_Store files found

There’s a tool called Asepsis, which does this. Asepsis creates a wrapper around Apple’s framework DesktopServicesPriv which is responsible for creation of .DS_Store files. This wrapper will redirect all the .DS_Store files into a single folder. The exact path of this folder isĀ /usr/local/.dscage.

Asepsis is available as a .mpkg file, so you’ve to install it manually. You’ve to restart your Mac to complete installation and Asepsis will start to run in background. So the next time a .DS_Store file gets created, it goes into the .dscage folder (which is where all .DS_Store files reside).

But Asepsis itself won’t migrate the existing .DS_Store files. For that, you have to fire up terminal and run its command line utility.

Running asepsisctl migratein will migrate all the .DS_Store files from your home directory to .dscage folder. But that’s not all! If you have websites in your /Applications, like me, you have to run asepsisctl --root /Applications migratein. This is because I have my WordPress site under MAMP which is in /Applications/ (and I obviously don’t want .DS_Store files in my site folder).

After you’ve done all this, you can check if .DS_Store files exist in a folder, by running –
find . -iname .ds_store.

One important thing to note is, Asepsis won’t work on Mavericks and you might even run into booting issues if you try to install it.

Thanks to Rakshit Thakker for the geeky tip!

Link: Asepsis