47

I use OS X Mavericks and have some company storage drives mounted (using smb or cfs). (smb://[email protected]/directory/data). When I work with files on the drive or copy files to the drive, some hidden files are created. Most of these files start with dot-dash ._ and then the filename of the original file, like:

._test001.png
._test002.png
._test003.png

And most of the times, the famous ._.DS_Store and .DS_Store are also there.

On my Mac, these . dot items are invisible, but my windows colleagues do see these files. How can I prevent OS X from making these strange invisible files?

On support.apple.com (and other internet sources) you can find a 'defaults write' to disable the creation of .DS_Store files on your network drives. But this does not work in Mavericks:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

For now I use this oneliner, but doing a rm -rf does feel wrong in this case.

find . -type f -name "._*" -exec rm "{}" \;

Edit: I don't want to delete the files or exclude them from copying. I want them not to be created in the first place.

Edit: I prefer a 'native' OS X solution over third party apps.

Edit: This questions has two answers, one for the ._ files and one for the .DS_Store files. The bounty is rewarded for dot_clean, this native command line app cleans all ._ files. Unfortunately is does not clear the .DS_Store files, this can effectively be done with Asepsis. Asepsis stores .DS_Stores in a fixed location, and not in the folder itself.

3
  • I'm not sure if these suggestions will solve your problem so leaving these in a comment. 1. Try TinkerTool bresink.com/osx/TinkerTool.html and use Finder > "Don't create hidden .DS_Store files over a network connection". 2. Try the Secrets System Preferences Pane secrets.blacktree.com and untick Finder > Use .DS_Stores on a network.
    – user26787
    Jun 26, 2014 at 18:04
  • @gentlemanhog, I'll try your suggestions. But I do prefer a 'native' OS X solution over thirdparty apps. Jun 27, 2014 at 7:44
  • @gentlemanhog, unfortunately your solutions do not work in Mavericks. Jun 27, 2014 at 8:27

8 Answers 8

37
+100

I will admit, I hadn't noticed that the defaults write command stopped working in Mavericks. However, when I DO clean network mounts, instead of your one liner find and rm, I use this:

dot_clean .

The manfile explains:

dot_clean -- Merge ._* files with corresponding native files.

I don't use the -m flag, but you may find it helpful in your situation.

-m      Always delete dot underbar files.

Here is another person actively trying to stop .DS_Store files from being created: http://www.aorensoftware.com/blog/2011/12/24/death-to-ds_store/ - looks like he doesn't want them on drives as much as he doesn't want them on the network!

1
  • This a the right tool for the job. Unfortunately this solution is 'post' mounting and needs to run after the mounting occurs. The asepsis does a better job (apple.stackexchange.com/a/136558/55028) but is a third party app and only works on .DS_Store files, and only works for all .DS_Store files on every mount. Jul 6, 2014 at 11:20
13

Just tried, and this does work in Mavericks (at least for disabling .DS_Store not network shares):

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

You just need to remember to restart Finder as well:

killall Finder
2
  • 1
    This does not work on El Capitan, for a Samba drive. .DS_Store files are still being created
    – Sébastien
    Oct 11, 2016 at 10:10
  • 1
    The .DS_Store are not AppleDouble files, they're just "normal" invisible files that are created by the Finder. So, your seeing of those .DS_Store files is no indication whether the DSDontWriteNetworkStores works or not. Dec 23, 2016 at 9:46
5

The ._ files are AppleDouble files that are used to store metadata like extended attributes, ACLs, file flags, and resource forks.

To delete them, run:

find . -name ._\* -delete

You can see if files have extended attributes, ACLs, or file flags with ls -l@eO. The ._ files are usually created because files have extended attributes. You can use xattr -c to delete extended attributes or chmod -N to delete ACLs. cp -X and rsync copy files without extended attributes, ACLs, file flags, or resource forks.

3
  • 1
    I do dont want to delete the files or exclude them from copying. I want them not to be created in the first place. Jun 30, 2014 at 9:04
  • 3
    If your using the Finder, you cannot prevent them from being created.
    – Fyrefly
    Jun 30, 2014 at 15:13
  • @Fyrefly, but you can create them somewhere else. See Asepsis, apple.stackexchange.com/a/136558/55028. So a 'native' solution might be possible as well Jun 30, 2014 at 21:33
4

As you would have to disable writing of hidden files on every Mac that could connect to your share, a better option would be to stop this at the share and not on the clients.

All you need to do is to edit your share config (for example in Linux in /etc/samba/smb.conf) and add the following option into your share config:

veto files = /._*/.DS_Store/ 

Now no Mac clients can save any files with those patterns to your share.

3
  • 3
    'veto files' does not prevent files being written, it prevents users from seeing the files. Please refer to samba.org Nov 18, 2015 at 11:16
  • 1
    samba has the option "delete veto files = yes" though, which also delete them.
    – rwenz3l
    Feb 22, 2017 at 12:03
  • 4
    Unfortunately, delete veto files = yes does not delete those dot files, it just insures that you can delete a folder that contains files that have been hidden from view by the veto files option, so it does not accomplish what the OP was after (and for what I am also vainly searching for).
    – xmnboy
    Apr 25, 2017 at 22:54
2

I have not tried this myself, and I realize the OP prefers native solutions, but nonetheless:

There's an app called Asepsis that works by redirecting creation of those files into a special folder, i.e. in a way preventing them from appearing.

1
  • This is a good tool for the job. Unfortunately this solution is a third party app and only works on .DS_Store files (not ._ files), and only works for all .DS_Store files on every mount. This is a good solution, but non native and non ._ files and therefor no bounty. sry. Jul 6, 2014 at 11:21
2

Not a native solution, nor does it actually prevent these files being written, but it does actively chase after them & delete as soon as they are written…

BlueHarvest

BlueHarvest automatically removes .DS_Store and ._ AppleDouble files from your USB keys, SD cards, music players, file servers or any non Mac disk. BlueHarvest removes these items as they’re created or modified so you’ll always be metadata free without you needing to lift a finger.

No affiliation, I've just been using it quite successfully for several years.

0

As far as I know you can not prevent that these files will be created. At least the Finder will create them.

Deleting these files will not help too - because the next time you access the volume and its folders on Mac, the Finder will create them again.

I am astonished that your Windows colleagues see these files. I am working for many years now with my Mac using Mac and Windows - and I never see these files. Neither on Mac nor on Windows.

These files are marked as "hidden" by default, and will not appear if you have Windows set to hide hidden files and folders.

4
  • I checked, and they do have disabled 'hide hidden files'. But this does not prevent them from being created. I think there is a way to fix this, as there was in OS 10.5 defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true Jun 30, 2014 at 10:52
  • If they disabled (unchecked) 'hide hidden files' then it is just the other way: enable it. :-) And as I said: as far as I know there is no "native OS X solution" solution. And: you linked to an answer from "support.apple.com" which says: "Disabling the creation of .DS_Store files on remote file servers can cause unexpected behavior in the Finder". And: I would not suggest to install applications which promises to prevent it. As far as I know this can be very dangerous.
    – Martin
    Jun 30, 2014 at 18:44
  • 2
    "this can be very dangerous" :) Now I really want these files gone! Seriously, .DS_Store files store Finder properties, and corrupted DS_Store files can do strange things indeed. I don't want corrupted DS_Store files, I want NO DS_Store files. I am not afraid of removing them. And back to my original question: How can I prevent OS X from making these strange invisible files? And with that I mean all ._ files and .DS_Store files. Nothing else. Jun 30, 2014 at 21:28
  • 1
    It would be helpful for me (and may be you) if you would confirm that the people enabled (and not disabled) "hide hidden files". And I can understand that you do not want that these files will be created and that you want a native solution, but if there is no native solution then it does not help to say "but I want it".
    – Martin
    Jul 2, 2014 at 19:27
-2

I found a very easy and free way to get rid go ._ files, especially from an external fat32 HD.

Launch OnyX (free software). From Utilities, go to AppleDouble, select... the folder. Thats it!!!

1
  • 2
    The OP quite specifically states he doesn't want a clean-up tool, but one that prevents the files being written at all.
    – Tetsujin
    Dec 27, 2015 at 9:39

You must log in to answer this question.

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