190

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 ?

iWizard
  • 6,816
  • 19
  • 67
  • 103
  • Dislike :) What should I use than? – iWizard Aug 02 '13 at 11:46
  • 1
    @CroiOS Terminal + VIM – Greg Aug 02 '13 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 Aug 02 '13 at 11:49
  • 7
    Just ignore the file in your version control system – millimoose Aug 02 '13 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 Jul 17 '14 at 19:13
  • As far as I can tell, `.DS_Store` files are only created when you look at the folder in Finder, so the only way to "prevent them from being created" is to not use finder. – Tadhg McDonald-Jensen Jul 20 '18 at 14:36
  • Check [https://github.com/xiaozhuai/odourless](https://github.com/xiaozhuai/odourless), I made a tool for preventing .DS_Store. – xiaozhuai Dec 13 '19 at 16:26

8 Answers8

44

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.

alper
  • 2,919
  • 9
  • 53
  • 102
Cristian Florescu
  • 1,660
  • 20
  • 24
  • 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 – Cristian Florescu Oct 24 '14 at 16:38
  • After each system upgrate needs reinstalation of latest version. – Cristian Florescu Jan 28 '15 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 Feb 21 '15 at 05:21
  • 1
    "Please install asepsis" Please could you show me some bash commands so I can just copy and paste these into my shell? – samthebest Jul 13 '15 at 10:00
  • # download installation package wget http://downloads.binaryage.com/Asepsis-1.5.1.dmg # mount volume hdiutil attach Asepsis-1.5.1.dmg # install sudo installer -pkg /Volumes/Asepsis/Asepsis.pkg -target / # unmount volume sudo hdiutil detach /Volumes/Asepsis # remove installation package rm Asepsis-1.5.1.dmg – Cristian Florescu Jul 14 '15 at 21:06
  • No additional updates under EL Capitan or later (because System Integrity Protection (SIP)) - http://asepsis.binaryage.com/#sip – Cristian Florescu Oct 01 '15 at 18:52
  • 3
    There is still a way to get Asepsis working under El Capitan. I've documented the steps here: http://pixelcog.com/blog/2016/disable-ds_store-in-el-capitan/ – mikegreiling Feb 27 '16 at 20:50
41

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.

Behrang
  • 46,888
  • 25
  • 118
  • 160
michel-slm
  • 9,438
  • 3
  • 32
  • 31
  • 6
    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 Dec 04 '14 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. – Nathan Tuggy Aug 09 '15 at 01: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.

Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
33

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

Christopher Bottoms
  • 11,218
  • 8
  • 50
  • 99
user3817989
  • 715
  • 1
  • 8
  • 11
-6

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.

Chris Johnson
  • 20,650
  • 6
  • 81
  • 80
Shanaka
  • 735
  • 6
  • 14
-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

-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

Swap
  • 237
  • 1
  • 2
  • 11
  • 6
    .DS_Store files are created by OSX Finder – Fran Marzoa Sep 28 '15 at 08: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. – Steve Buzonas Aug 13 '16 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).

Ryan K
  • 3,985
  • 4
  • 39
  • 42