At the request of a reader, I went ahead and researched what .DS_Store Files are, and how prevent MacOS X from creating them. In a nutshell, .DS_Store files are created by Finder to store preferences:
.DS_Store (Desktop Services Store) is a hidden file created by Apple Inc’s Mac OS X operating system to store custom attributes of a folder such as the position of icons or the choice of a background image. By default, Mac OS X will create a .DS_Store file in every folder that it accesses, even folders on remote systems (for example, folders shared over a SMB or AFP connection) and even if the user has only customized the appearance of the folder by moving its Finder window. This is in contrast to the preexisting system for the same purpose used in previous versions of the Macintosh Finder, which would merely place a number of invisible files at the root of the volume being accessed (even on alien filesystems), always storing the settings and metadata for all of the folders in the entire volume within this single set of files.
Unfortunately it seems that you can only prevent Finder from creating these files on network shares and not on your local machine. Here’s how you do it:
- Open the Terminal application (though I highly recommend using iTerm instead)
- Type in the following command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
and press enter
- Reboot your machine so that the changes will take effect
I haven’t found a good way to prevent OS X from creating them on local file systems, but perhaps someone out there has some suggestions? Other than creating a script to delete them and adding it to cron, I’m not sure of a way to at least clean them up in an automated fashion. I did run across an application called DS_Store Cleaner which helps clean-up said files, though.










By Cliff December 5, 2007 - 10:37 pm
These files are even more insidious than the Windows thumbs.db files… at least in Windows we only had the .db files when there were pictures in the folder… on the Mac it’s every folder… not a big deal unless you use a product like Eclipse which shows you all of these files!
By Alexandre July 15, 2008 - 7:50 am
Good tip. Tks!
By Thomas December 2, 2008 - 3:01 pm
Thank You!!!
By Pablo RuiZ December 19, 2008 - 10:09 am
There’s a Mac App called Blueharvest, costs like 12 dollars but allows you to prevent creation of .DS_Store files on local volumes.
By if you delete a ds_store file, the finder automatically recreates it when the folder is accessed again right? - QuestionBin - Intelligent Answers for Smart Questions::Answer November 13, 2009 - 6:49 pm
[...] Yes, that is correct. There are ways to disable it. Disable ds_store creation over network Disable Over Network Stop the Creation of ds_store files [...]
By Amol October 12, 2011 - 7:42 pm
You can run the following in a terminal to clean up .DS_Store files on your root drive (/).
find / -name .DS_Store -exec rm {} \; -print
However, these get recreated when you navigate to a folder in finder.