mattgadient.com

removing .DS_Store

Mac OS X is a fantastic OS. It’s not perfect though, and there are a few annoyances that do come along. One is that it creates a file called “.DS_Store” in every folder which contains information about that folder.

That’s all fine and dandy, as it’s a hidden file anyway, and it’s used by OS X. The problem is that it also insists on creating these files both on network drives as well as removable media. This extra “clutter” can be irritating, and here’s the way to remove it.

First, to disable the creation of .DS_Store on network volumes (found here):

  1. Open a terminal.
  2. Type the following:
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true
  3. Hit enter, restart the computer, and you’re done.

Next, removing the .DS_Store file from a current volume (such as a USB Memory Stick). Note that these will be recreated at some point regardless of whether you use the above option (it only applies to Network drives).

  1. Simply open a terminal, and head to whatever volume you want to access.
    (cd "/Volumes/NO NAME" for example)
  2. Type the following:
    find . -name ".DS_Store" -ok rm '{}' ;
    OR
    find . -name ".DS_Store" -exec rm '{}' ;Update: This has changed in newer versions of Mac OS. It is now:
    find . -name “.DS_Store” -delete

    The first one will give you a yes/no prompt before deleting each. The second will just go ahead and delete them all. No before you ask I didn’t figure those out myself, I found them here (Web Archive). Make sure you’re in the right place before running the 2nd part (if you don’t change to the directory/volume first, you may end up accidently removing all copies of “.DS_Store” on your system which may not be what you want).

As always, there are no guarantees, and if you mess up your system, well… you’re on your own.