Is there a way (eg. a binary hack into Finder) to stop it from creating .DS-Stores on LOCAL Volumes?

I am using Leopard, therefore these don't work:

Also, BlueHarvest slows down my computer.


6 Answers 6


Third party solutions

In my experience, BlueHarvest is best in class. Technically, it is not an answer to the question; it can remove but not prevent .DS_Store files.

If BlueHarvest is effective but does not suit your use case, it becomes difficult to give an acceptable answer to your question.

If you have no acceptable third party solution, then you must work with what's integral to Leopard …

Without a third party solution: restrain your use of Finder

By avoiding the views that you do not wish to save, you can prevent creation of .DS_Store files.

Most users will find it difficult to restrain themselves in this way, but it's a true answer within the limitations of the question.

http://diigo.com/0qiwp for an annotated view of http://lists.apple.com/archives/applescript-users/2006/Jun/msg00180.html where Matt Deatherage (a former engineer at Apple) explains .DS_Store and other types of file.


To prevent those ugly .DS_Store files from showing up there seems to be a relatively new option to do this cleanly, not only for network drives, like:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

but also for USB-connected volumes:

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Relative to the OPs question title, this is the best solution without hacks, since it addresses not only the network misbehaviour but is also effected for most connected disks. And those might be the biggest annoyance for most users sharing devices like USB sticks between different environments. It uses only Apple provided options and doesn't interfere with normal operation in any way.

Relative to the concrete situation explained in the OPs body it is of limited value, since this USB option is only available in later versions of OS X/macOS. Further, this still does not address the problem of .DS_Store creation on internal disks, where they can be also a hassle to deal with. Although in that place they might actually serve some kind of purpose.

A more comprehensive solution to this problem, albeit a more hackish one, that works on most versions of the Mac operating system is as follows: To completely nuke this nasty behaviour on all disks – and with a binary patcher/code injector like the question of the OP longs for – there is DeathToDSStore / with source.

Both of these options assume that anyone still uses Finder… Using a different file manager would also solve this problem. There are numerous contenders to replace Finder for file management on macOS. Two of the top dogs in this field are Pathfinder or XFile.

  • 3
    +1 for the USBStores command (I didn't know that one!) as well as DeathToDSStore. Commented Aug 29, 2017 at 13:52
  • This answer does not seem to work for the local disk partition.
    – Alex
    Commented Sep 11, 2020 at 14:31

I haven't found any way to keep them from being created, but you can delete them automatically with a script:


find ~ -name .DS_Store -exec /bin/rm -f -- {} \;

exit 0

Run it every X minutes via launchd or cron. It takes almost no time to run on my several-year-old iMac. It will only search your $HOME (~) but that's where most of them will be. Change ~ to / if you want to delete them across the entire drive, but that will take much longer to run, so adjust the frequency accordingly.

  • 2
    You could also use find ~ -name .DS_Store -delete. And don't forget the -name flag — without it the command would apply to all files in ~ and ./.DS_Store.
    – Lri
    Commented Nov 27, 2011 at 0:50
  • 2
    I know that I can use a script, but your answer doesn't answer he question.
    – kinokijuf
    Commented Nov 27, 2011 at 11:29
  • The answer to the question is "no." There isn't a way to stop them from being created (except on network shares, which also wasn't the question). This answer tries to achieve the same end result. If SE had a category of reply called "Workaround" I would have put it under that. It's certainly no worse of an "answer" than a daemon attaching to a framework (<asepsis.binaryage.com/>), and much safer than hacking into a system binary, and it runs on any version of Mac OS X.
    – TJ Luoma
    Commented Nov 29, 2011 at 19:56
  • Except it doesn't achieve the same end result. Blueharvest is a better workaround (same end result, save for the fact that the computer runs loke a hog). Also asepsis is a driver IIRC.
    – kinokijuf
    Commented Nov 30, 2011 at 12:49
  • 1
    @kinokijuf, drop the entitled attitude. When someone offers you free help, you don't get to criticize it. It's fair to simply state, once, that it's not what you're looking for, but TJ Luoma's defense (which you made sadly necessary) is more than enough of a cue for you to shut up. Jeez. Commented May 19, 2017 at 0:13

Try this command in terminal:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

It seems to work for me.

  • 5
    It works only for network, not for local volumes.
    – kinokijuf
    Commented Nov 15, 2011 at 14:20
  • You are correct. I apologize for my confusion.
    – Siriss
    Commented Nov 15, 2011 at 19:03
  • 4
    This is the only real case in which i could see .DS_Stores being annoying. They're hidden on Mac OS by default, and are crucial for saving view settings for individual folders
    – Alexander
    Commented Nov 26, 2011 at 23:24
  • 2
    But I don't want to save view settings.
    – kinokijuf
    Commented Nov 27, 2011 at 9:27

I had the same problem, and solutions to prevent those annoying files on the local mounted disk did not work for me.

In the end I have found a suitable solution, which is to periodically search and remove these files on the local mounted disk only. I added a cronjob with the following content:

9 */1 * * * find -x ~ -path /Users/adietz/Library -prune -o -fstype local  -name .DS_Store -print -exec /bin/rm -f -- {} \; >> ~/.cron.log 2>&1

Here is what it means:

  • 9 */1 * * * performs the command every 9 minutes after the hour (so 10:09, 11:09, 12:09, ...)
  • find -x ... -fstype local (optional) Perform the search only on the local mounted file system and ignore any other mounted disk under ~
  • ~ the folder to search (home folder)
  • -path /Users/user/Library -prune -o (optional) expression to NOT look in the Library folder (which might throw Input/Output errors).
  • -name .DS_Store the file name to look for
  • -print (optional) print a found occurrence
  • -exec /bin/rm -f -- {} \; remove the file
  • >> ~/.cron.log 2>&1 (optional) Adds the output to a file, so you can check that it works, and where the annoying files have been removed

EDIT: apparently no longer works in newer macOS versions

I've made a more efficient script (intended to be run continuously as daemon), it'll do one execution of find at the beginning to wipe already existing files and it'll catch new files in real time via fsevents. So they will be nuked immediately as they are created, and resource usage is very low. AFAIK this is the best possible way to get rid of them without disabling SIP.
Here it is — https://github.com/magicgoose/DS_Store-Kill

  • This suggestion does not work. The files are still created.
    – Alex
    Commented Sep 15, 2020 at 7:01
  • sorry about that. there were several macOS releases since then, and I didn't maintain this script because I quitted using macOS as my primary OS. Commented Oct 13, 2020 at 8:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .