195

I'm developing sites on mac and every time I create some folder (or file in that folder) .DS_Store is created in that folder.

How to prevent creating .DS_Store file ?

7
  • Dislike :) What should I use than?
    – iWizard
    Commented Aug 2, 2013 at 11:46
  • 1
    @CroiOS Terminal + VIM
    – Greg
    Commented Aug 2, 2013 at 11:47
  • It was a comment as no real alternative - in theory you could use the Terminal only or other tools e.g. editors ( or I think Path Finder as a file browser) but in practice you are stuck with these files
    – mmmmmm
    Commented Aug 2, 2013 at 11:49
  • 7
    Just ignore the file in your version control system
    – millimoose
    Commented Aug 2, 2013 at 11:56
  • 6
    This question appears to be off-topic because it is about Apple hardware and software - best fit would be Ask Different.
    – Dan J
    Commented Jul 17, 2014 at 19:13

8 Answers 8

43

Please install http://asepsis.binaryage.com/ and then reboot your mac.

ASEPSIS redirect all .DS_Store on your mac to /usr/local/.dscage

After that, You could recursively delete all .DS_Store from your Mac.

find ~ -name ".DS_Store" -delete

or

find <your path> -name ".DS_Store" -delete

You should repeat procedure after each major Mac update.

7
  • 1
    Note for Mac OSX 10.10 you should upgrade Xcode Command Line Tools and after that manually run in terminal like root or with sudo the following command xcrun --find codesign. Manually accept License term and agreement and the you could continue asepsis installation Commented Oct 24, 2014 at 16:38
  • After each system upgrate needs reinstalation of latest version. Commented Jan 28, 2015 at 20:27
  • 1
    "Asepsis implements a system-wide daemon asepsisd whose purpose is to monitor system-wide folder renames (or deletes) and mirror those operations in the prefix folder" This was written on Asepsis' page. Is it really required to recursively delete the .DS_store files?
    – vanguard69
    Commented Feb 21, 2015 at 5:21
  • 3
    "Please install asepsis" Please could you show me some bash commands so I can just copy and paste these into my shell?
    – samthebest
    Commented Jul 13, 2015 at 10:00
  • 3
    There is still a way to get Asepsis working under El Capitan. I've documented the steps here: pixelcog.com/blog/2016/disable-ds_store-in-el-capitan Commented Feb 27, 2016 at 20:50
40

NOTE: "Asepsis is no longer under active development and supported under OS X 10.11 (El Capitan) and later."


Here's a comprehensive review of your options. Asepsis (the second solution mentioned) seems to be what you're looking for, it re-routes .DS_Store creation to a unified cache instead of being located on every folder.

2
  • 7
    In case the link ever goes bad, the two most likely options listed on that site are Asepsis (redirects created files) and DeathToDSStore (prevents file creation, disabling some Finder features), both of which are described in answers on this page. The other options deal with network drives and external drives - both of which only solve part of the problem.
    – sage
    Commented Dec 4, 2014 at 17:13
  • 1
    @emmanuel: This does include the essential parts: the name of a program and the specific feature it provides to solve the problem. Commented Aug 9, 2015 at 1:02
36

Its is possible by using mach_inject. Take a look at Death to .DS_Store

I found that overriding HFSPlusPropertyStore::FlushChanges() with a function that simply did nothing, successfully prevented the creation of .DS_Store files on both Snow Leopard and Lion.

DeathToDSStore source code

NOTE: On 10.11 you can not inject code into system apps.

4
  • Please could you provide some bash I can copy and paste into my shell. This solution requires quite a bit of engagement with the literature.
    – samthebest
    Commented Jul 13, 2015 at 9:58
  • 4
    You can use DeathToDSStore.app Commented Jul 13, 2015 at 10:16
  • 1
    Is there a 2019 solution? As DeathToDSStore doesn't seem to be working on latest MacOS's anymore...
    – jnaklaas
    Commented Oct 31, 2019 at 8:48
  • @JKL I am not aware of any working solution. Commented Oct 31, 2019 at 9:08
36

Open Terminal. Execute this command:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Either restart the computer or log out and back in to the user account.

for more informations:

https://support.apple.com/en-us/HT208209

3
  • 72
    only applies to network filesystems Commented Sep 18, 2014 at 9:44
  • 2
    updated link: support.apple.com/en-us/HT208209
    – Felix
    Commented Oct 19, 2020 at 1:57
  • 4
    defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true is the same for USB drives.
    – thakis
    Commented Apr 15, 2023 at 21:22
-7

Put following line into your ".profile" file.

Open .profile file and copy this line

find ~/ -name '.DS_Store' -delete

When you open terminal window it will automatically delete your .DS_Store file for you.

3
  • 10
    running this at login slowed things down, so I just made this alias: alias nomore='find ./ -iname .DS_Store -delete' Commented Nov 5, 2014 at 21:20
  • 4
    So, is [/irony off] turning your irony off or ending your irony being off making it turn on?
    – Connor
    Commented May 15, 2019 at 19:52
  • 1
    This is a great way to kill (productive) time while mac searches hundreds of K's of files on disk. Commented May 15, 2020 at 3:19
-10

this file starts to appear when you choose the system shows you the hidden files: $defaults write com.apple.finder AppleShowAllFiles TRUE If you run this command disapear $defaults write com.apple.finder AppleShowAllFiles FALSE Use terminal

1
  • 5
    The question asks how to stop the files from being created, not how to hide them. Commented Aug 13, 2016 at 19:21
-10

the function

find ~/ -name '.DS_Store' -delete

, removed the .DS store files temporarily. But am not sure , whether the files will came back on the Mac. Also i noticed something peculiar, the "DS_Store" start coming to the Mac after installing 'ATOM'. So guys please make it sure to scan properly your third party software before installing them. Best

2
  • 6
    .DS_Store files are created by OSX Finder Commented Sep 28, 2015 at 8:41
  • 2
    The question asks how to stop the files from being created. This answer is how to delete them. Additionally, ATOM is not creating the files. The Finder application creates them when visiting a folder to store icon positions, selected view for the folder, background image, etc. DS_Store, DS is Desktop Services. Commented Aug 13, 2016 at 19:25
-15

If you want the .DS_Store files to become invisible (they still exist but can't be seen) then run the following command in the "Terminal" window:

defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder

This will set the system default to stop showing these files on your Desktop and elsewhere. It will also restart the Finder in order to make this change visible (especially on your Desktop).

3
  • 8
    That's not answering the question that was asked.
    – nobody
    Commented Aug 8, 2015 at 22:45
  • Hiding the showing of hidden files is not removing the creation of .DS_Store files, which is the question that was asked. This is a terrible answer. Commented Jun 8, 2016 at 9:48
  • 1
    The question asks how to stop the files from being created. This solution hides them (and other files) only in Finder. Commented Aug 13, 2016 at 19:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.