Prevent creation of file .DS_Store

When OSX access to SD, external USB disks or NAS (NFS, SMB,..) some hidden files are created :

  • .DS_Store : file created by finder in order to store information such as position of window, icon, label color…
  • Apple Double Format : are files with prefix “._” such as for example  ._image.jpg and its companion  original file image.jpg. OSX’s file-system supports forked files and when you access to different system which doesn’t support forks (for example a samba disk resource) OSX creates files with a mechanism called “Apple Double” which are files with prefix ._ that contains fork information. Generally you can safely deleted it.
  • .Spotlight-V100 (however I never see it on remote resources) : index and metadata for Spotlight (search).
  • .Trashes and .Trash (however I never see it on remote resources) :  files which are put in trash but not deleted yet.

This could annoy  other users if disk resource is used by several users with different OS (for example Windows users).

Those files are hidden and invisible from your Mac (or other Unix-like OS) since they have prefix . (dot) which specifies that this files has to be ignored in file listing (you show it if you use ls -la in Terminal). However are not invisible for other system.

 ls -la 
 drwxrwxrwx    4 giovanni hdusers       151 Apr 30 17:58 .
 drwxrwxrwx   12 root     root         4096 May  1 01:00 ..
 -rwxrw-rw-    1 giovanni hdusers      6148 Apr 30 01:54 .DS_Store
 -rwxrw-rw-    1 giovanni hdusers      4096 Apr 30 01:56 ._.DS_Store
 -rwxrw-rw-    1 giovanni hdusers      4096 Apr 30 01:56
 -rwxrw-rw-    1 giovanni hdusers      4096 Apr 30 01:56 ._readme.txt
 -rwxrw-rw-    1 giovanni hdusers      4096 Apr 30 01:56 ._usr
 drwxr-xr-x    2 root     root           89 May  1 01:32 config
 -rwxrw-rw-    1 giovanni hdusers       426 May  1 01:33
 -rwxrw-rw-    1 giovanni hdusers      2616 Apr 26  2008 readme.txt
 drwxrwxrwx    4 giovanni hdusers        88 Apr 30 01:54 usr

Prevent #1

You can create a veto on server side about those files.
For example on samba server edit /etc/samba/smb.conf and add

veto files = /.*/.DS_Store/

But you have to have access to all servers that you usually use  … obviously this doesn’t work for USB Disk, SD…

Prevent #2

Open shell (Terminal) and execute  command:

defaults write DSDontWriteNetworkStores TRUE

check it by command (you have to get true as result):

defaults read DSDontWriteNetworkStores

You have to log out and  log in order to activate new setting.

Prevent #3

Probably this is the best choice :
A nice little program that saves me a lot of tedious cleaning up, and saves my windows-using colleagues a lot of confusion
This program allows to prevent creation of  those files on external resources. You can edit and create profile for each resource.


Clean up from .DS_Store (delete all)

Warning : you have to check before to execute below commands. You are responsible for deletion of files.

Warning : Command on BusyBox v1.1.1 (find syntax can be different)

First off count number of files :

find ./ -iname ".DS_Store" -o -iname "._*" | wc -l

Before to delete (7759 files) check what you’ll delete :

find ./ -iname ".DS_Store" -o -iname "._*"  -exec basename {} \;

Delete files:

find ./ -iname “.DS_Store” -o -iname “._*”  -exec rm {} \;

Warning  : before executing above command you have to check what will be deleted

User Review
0 (0 votes)