Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Prevent .DS_Store file creation on network volumes Network
This KnowledgeBase article explains how to prevent OS X from creating new .DS_Store files when opening folders on remote volumes mounted using SMB/CIFS, AFP, NFS, and WebDAV. The creation of .DS_Store files (and more so, ._AppleDouble files which are not covered in this hint) is frequently the source of complaints against Mac users, who often leave a trail of these files scattered throughout the filesystem when "visiting" a Windows computer. Even with this hint in place, the .DS_Store files will continue to be created on local volumes (which is a good thing).

To prevent the creation of these files, open the Terminal and type:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
It may be necessary to log out and back in, or even to restart the computer (which is what the article states), for the change to take effect.

Note: Most of the settings controlled by data in .DS_Store files are "cosmetic" in nature -- for example, Finder window position, view style, icon position, etc. However, .DS_Store files in OS X also store Finder "comments" so in this sense, disabling .DS_Store files may result in loss of data.

[robg adds: In my previous day-job, I know a feature like this would have been highly welcomed by our sys admins. I used some of the previous hints here to try to erase my trails, but this is a much nicer solution!]
    •    
  • Currently 3.31 / 5
  You rated: 4 / 5 (16 votes cast)
 
[263,658 views]  

Prevent .DS_Store file creation on network volumes | 48 comments | Create New Account
Click here to return to the 'Prevent .DS_Store file creation on network volumes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Prevent .DS_Store file creation on network volumes
Authored by: thirteenva on Jul 13, '05 10:16:31AM

Can anyone confirm if this will work in Panther? Or if there is another method that will stop he .DS_Store files in panther?



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: nikgreen on Jul 14, '05 07:16:27AM

Yes it does work on Panther.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: thoughton on Jul 14, '05 08:30:59AM

Why don't you just try it fer chrissakes. It's not like it will take you more than 5 seconds to cut and paste the SINGLE command into your terminal window. I've heard of hand-holding but this is ridiculous.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: genericuser on Nov 30, '05 10:06:59AM

That's true, but now every Panther user who comes along can save themselves that five seconds. It's not just thirteenva who can use that information.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: Christoph on Jun 28, '06 05:14:11AM

No, it does not work on Panther.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: JoolsG4 on Jul 13, '05 10:16:38AM

Is there a similar tip for stopping these files appearing on mounted non-Apple volumes, such as memory sticks, digital camera's, my Sony PSP and my SonyEricsson K750i mobile phone?

Whenever I mount one of these on my desktop and copy/modify any files, the Mac OS (un)helpfully creates all these hidden files, which obviously the PSP and K750 don't understand.

Currently I have to use a third party 'cleaner' application to manually delete all these files before un-mounting the device. If it was possible to stop them being created in the first place it would help immensely.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: paperwings on Jul 13, '05 11:08:47AM

Yes. Or mp3 players for those of us who haven't joined the iPod "revolution".



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: macslut on Jul 13, '05 11:37:03AM

What third party cleaner do you use? I've had mixed results and even resorted to using VirtualPC for keeping my MemoryStick clean, which isn't just an inconvenience in my case, those files cause a direct conflict.



[ Reply to This | # ]
Shell Script cleanup
Authored by: lullabud on Jul 13, '05 06:27:46PM
I use /bin/sh! Seriously, I use something very similar to the following to keep my CVS server's repository clean of excess junk, including Apple, Windows, Paintshop Pro and ws_ftp crap. It requires root privs.
find /Volumes/PSP/ | grep -ir '\(\._\..*\|\.AppleDouble\|\.AppleDesktop\|ws_ftp\.log\|Thumbs\.db\|pspbrwse\.jbf\)$' \
| sed 's/^\(.*\)$/rm -f "\1"/' | /bin/sh
*Note: I'm no bash überguru, so this might not be the most effective way to get it done, but I do use that grep, sed and sh string on a production Debian server at work. I did test the non-linux command modification to see if it would delete anything crazy on my Powerbook and it didn't. To see what would have been deleted without actually deleting anything, just remove the "| /bin/sh" from the end of the command. It will then just print out a bunch of "rm -f" commands which don't actually do anything.

[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: jedik on Jul 13, '05 11:50:38PM

You may try to use FinderCleaner:

http://www.macupdate.com/info.php/id/16996

It's a freeware utility that removes such files before ejecting an external device.

Cheers

---
:: Jedi Knight ::
-- Mac Rules! --



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: diamondsw on Jul 13, '05 10:29:27AM

Well thank GOD for this hint. Now could someone tell me *why* this isn't the default?

Furthermore, I agree with the other poster - if there's a way to keep it from littering my flash devices as well, I'd be all ears.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: wibbble on Jul 13, '05 06:53:48PM

Well, if you're only using AFP volumes, you might actually /want/ them to be created.

I'd love to be able to disable them for everything but AFP, but that doesn't appear to be an option.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: abyone on Jul 13, '05 11:30:40AM
It would be interesting if we could apply this preference to a network domain, so that all users in a company (for example) would automatically get the pref, as long as they don't overwrite it. That way users wouldn't need to remember to make this change, and everyone in the network would just behave "better" by this standard.

More Info:
In theory there are 3 sets of preference locations on a mac:
~/Library/Preferences
/Library/Preferences
/Network/Library/Preferences

The Pref system is supposed to use a known order of searching to find a pref, starting at the top of the list, working its way down (I don't know if the order I gave is the search order, btw). If none of the locations have the pref set, then a default, choosen by the app is used.

This would allow The same file to exist on all three locations, but allow an admin to set some network wide prefs in the /Network folder (not necessarily all the prefs either, just one key-value pair), somebody to set some prefs for the machine, and then the user to override the prefs for when they are logged in.

I actually have never seen the /Network prefs used, but I've also never been in a managed macintosh network environment. Whether or not the network domain ever got implemented I don't know, and how the /Network/Library folder would even get created or accessed, I am unsure.

Just thought it would be interesting to see this pref get set in the /network domain, so each individual user in the company would not have to set it each time they got a new mac or re-installed the OS, etc.

links:
http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Concepts/UserPreferences.html

[ Reply to This | # ]

10.4: Prevent .DS_Store file creation on network volumes
Authored by: mikepak on Jul 14, '05 06:32:37PM

I need to find a way to do this for my work, i cant seem how to set a preference qualifier when i write the plist

if ANYONE knows how to do this, so any user loging on doesnt leave .ds_stores everywhere, please let me know



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: JoseyWales on Jul 13, '05 11:44:57AM

Excellent! Now, if only I could get it to stop saving ._filename.htm files every time I edit filename.htm over the network using BBEdit...



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: kyngchaos on Jul 13, '05 12:14:16PM

Turn off the BBEdit preference to save state, it adds a resource fork to the file, which is what those ._files are (I think) -

Text Files: Saving - Save Document State

Too bad you can't do this per document (I couldn't find it if there is), there are some files I would like to save state, but mostly I don't ( or don't care).



[ Reply to This | # ]
BBEdit document state
Authored by: DavidShepherdson on Jul 14, '05 01:17:45AM

More recent versions of BBEdit (at least since version 8) store document state in the preference file instead of the document's resource fork, so this should no longer be a concern.



[ Reply to This | # ]
BBEdit document state
Authored by: Tom Robinson on Jul 14, '05 02:07:11AM

It is still a 'concern', because if you're not on an HFS volume, the type and creator code are also stored in the .DS_Store--it's not just the resource fork in there, but also meta data.



[ Reply to This | # ]
BBEdit document state
Authored by: derekhed on Dec 06, '05 02:41:03PM

I have turned off 'save document state' in BBEdit 8.2.4 and I still get the dot underscore files when saving to our Win2000 Server. Can anyone verify that this advice actually works for them?



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: gbrandt on Jul 13, '05 01:05:23PM

Hah,

Where I used to work we called it 'Mac Spoor'



[ Reply to This | # ]
APPLE! Suggested Feature. Plus, Removal Tip
Authored by: Lectrick on Jul 13, '05 02:37:53PM
Good Lord, the Finder should store all this info (.DS_Store, ._resourcefork) in the root of the drive (perhaps analogous to OS 9's DesktopDB and DesktopDF) and transfer it with the file if requested and that's it. Peppering every damn directory with this info is an extremely ugly (and wasteful... each file takes up to two 4k disk blocks even though it's a 5k file or so) way to go about storing Finder-specific information.

If that is not an option, we should at least be able to disable this "feature" on a drive-by-drive (or network-share-by-network-share) basis. I don't want my iPod Shuffle (which I use at clients who are unfortunately on Windows) to be peppered with these files, at all! (I wouldn't mind a single dot-file at the root level, though.)

Meanwhile there is always this command, which you can make into a dropscript and make drag and drop:

find "$@" \( -name ".DS_Store" -or -name ".Trashes" -or -name "._*" \) -exec rm -rf "{}" \; -prune

This will remove all .DS_Store, .Trashes, and dot-underscore-prefixed resource fork files from a given directory and its children. (If you are running it by itself as opposed to inside a dropscript app, change "$@" to "." and CD to the appropriate drive first. Remaining tweaking is left as an exercise for the reader.)

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]

NOTE: Parentheses are missing escapes
Authored by: Lectrick on Jul 13, '05 02:42:08PM
Damn it, the webpage removed the
\
escape character before the ( and ) characters, above- even though I specified it as tagged code! It will not work without that. If it is possible for an editor to change that, please do.

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]

::sigh:: So was the semicolon!
Authored by: Lectrick on Jul 13, '05 02:44:24PM
Ugh, web form encoding, grrr.

Please also put a backslash before the semicolon in my original post (as well as before the parentheses). Again, if an editor can tweak this post-post, please do.

Peter

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]

APPLE! Suggested Feature. Plus, Removal Tip
Authored by: bobbob on Jul 13, '05 04:02:17PM

What are you going to do if someone does 'ln -s / ._foo' and then you run this script?



[ Reply to This | # ]
Good point.
Authored by: Lectrick on Jul 13, '05 07:35:35PM

In the case of files, perhaps I will have to restrict the filetype to "file" as opposed to "directory", or perhaps there's an option (probably, but not at my computer currently) to not follow symlinks.

Good point, however. Obviously the ultimate ds_store removal one-liner is still in active development...

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]
Good point.
Authored by: raider on Oct 13, '06 09:54:12AM
Obviously the ultimate ds_store removal one-liner is still in active development...
What is wrong with:

find . -name .DS_Store -print -delete


[ Reply to This | # ]
APPLE! Suggested Feature. Plus, Removal Tip
Authored by: Anonymous on Dec 05, '06 11:21:23AM
You're talking FUD. From man find:
 -P     Never follow symbolic links.  This  is  the  default  behaviour.
        When find examines or prints information a file, and the file is
        a symbolic link, the information used shall be  taken  from  the
        properties of the symbolic link itself.
This means that, with find, even without the -P option, will instruct rm to operate on the symlink, not its target.

[ Reply to This | # ]
APPLE! Suggested Feature. Plus, Removal Tip
Authored by: Tom Robinson on Jul 14, '05 02:10:21AM

While I agree this behaviour is annoying, opening up write access to the root of a file server volume can be extremely unwise! Hence Apple's decision to do it per directory...



[ Reply to This | # ]
APPLE! Suggested Feature. Plus, Removal Tip
Authored by: Elander on Jul 14, '05 09:40:26AM

Well, maybe not. Files prefixed with "._" contain all of the metadata for their un-prefixed partner that the native volume format cannot contain in a single file: resource forks, flags, dates, and now in Tiger, extended attributes.

You can run into nasty side effects if you always remove them. Although resource forks should be a thing of the past now, extended attributes will probably be of substantial use in the not so distant future.

---

/elander



[ Reply to This | # ]
APPLE! Suggested Feature. Plus, Removal Tip
Authored by: grahamperrin on Jan 02, '08 12:58:28PM
Finder should store all this info (.DS_Store, ._resourcefork) in the root of the drive

Not a good idea. Less privileged users should not have have write privileges to the root of shared drives such as server volumes.

So, Finder writes to more appropriate paths.

Attempts to write to the root of a volume can be terribly problematic. See for example WebDAV (PLIP #187) and Microsoft Office 2004 and related links.



[ Reply to This | # ]
10.4: Prevent .DS_Store file creation on network volumes
Authored by: mmmmark on Jul 13, '05 04:21:02PM
I use a nice little gem called KopyMac to move picture files to a flash drive or compact flash card (or even CD) before I take them to be printed.

It prevents all the .DS store files (during the copying process) so the idiots don't try to print zeroK files and try to charge me.

Link to KopyMac Developer Page



[ Reply to This | # ]

Path Finder, too
Authored by: neilio on Jul 14, '05 10:14:02AM
Or you could just use Path Finder, which doesn't create or add .DS_store files whatsoever... :)

---
Slumming at http://www.beatnikpad.com/

[ Reply to This | # ]

If it doesn't work,
Authored by: newbish on Jul 14, '05 10:32:12AM

Initially, this didn't work for me. After reading the original Apple technote, it occurred to me that perhaps the generated plist file wasn't going to the correct place. Though it was in my user's Preferences, it was not in the system preferences.

I tried copying the newly created ~/Library/Preferences/com.apple.desktopservices.plist to the main system preferences folder: /Library/Preferences/. Then restarted my computer.

Now it works.

With the original suggestion, would it be possible that the user needs to be root before generating the defaults command?

A Little History

Interestingly enough, this is not a new problem. In fact, it may be one of the oldest problems of all the Apple operating systems!

Way back in the early days, just after the stone wheel and before sliced-bread, we had portable disks with the enormous storage capacity of 800 KB! As Apple introduced a GUI desktop to the Apple II line, the OS used to leave similar files all over the place. We referred to them as Finder Turds. Because storage was such a tight commodity, these little files were enormously unpopular, and people complained bitterly about them. Indeed, there was quite the movement to wipe them out, just as we are seeing here.

You think the newest generation of Apple engineers would have learned from the previous generations.



[ Reply to This | # ]
If it doesn't work,
Authored by: simbalala on Nov 06, '05 03:04:33PM

<blockquote>Initially, this didn't work for me. After reading the original Apple technote, it occurred to me that perhaps the generated plist file wasn't going to the correct place. Though it was in my user's Preferences, it was not in the system preferences.

I tried copying the newly created ~/Library/Preferences/com.apple.desktopservices.plist to the main system preferences folder: /Library/Preferences/. Then restarted my computer.</blockquote>

At first I thought it wasn't working so I did the same, copied the ~/Library... file up to /Library... (there was no such file there before) but now I figure that I'm looking at the wrong files on the server and confusing myself. I don't get .DS_Store files and did not before I copied the prefs file upwards either.

But I always do get the ._AppleDouble files (ie: image.jpg and ._image.jpg) though and in the case of small images they're more than double the size of the actual image.

I've searched around and found no way to turn these off and some controversy about whether they can be safely deleted or not. I'm thinking that for Linux purposes when I don't care about bringing the files back into the Mac it doesn't matter.

Any thoughts on this? Anyone?



[ Reply to This | # ]
If it doesn't work,
Authored by: DavidRavenMoon on Dec 05, '06 12:34:33PM
But I always do get the ._AppleDouble files (ie: image.jpg and ._image.jpg) though and in the case of small images they're more than double the size of the actual image. I've searched around and found no way to turn these off and some controversy about whether they can be safely deleted or not. I'm thinking that for Linux purposes when I don't care about bringing the files back into the Mac it doesn't matter.


Those are thumbnails, and/or image previews. Try setting what ever graphics application you are using to not save a preview/thumbnail. That way there wont be any resource forks in the files.

---
G4/Digital Audio/1GHz, 1 GB, Mac OS X 10.4.8 • www.david-schwab.com

[ Reply to This | # ]

Prevent .DS_Store file creation on network volumes
Authored by: name99 on Jul 14, '05 05:31:10PM

"Even with this hint in place, the .DS_Store files will continue to be created on local volumes (which is a good thing). "

Dammit, why do people make excuses for Apple? They'll only fix things when enough people complain.
As one earlier poster said, creating .DS_Store files is NOT a good thing. It is a stupid pathetic hack, the sort of thing an amateur programmer would come up with. There are a dozen different ways one can imagine the Finder storing the various things it wants to know about how to display a particular directory, all of which don't have this horrible impact on the user.

The fact of the matter is that, five years after OS X was released, the Finder is still a POS. Readers of this website should get serious about FTFF --- whenever you have a chance to meet with an Apple person, raise the issue and don't let go. It is very nice that Apple has smart people working on file systems, metadata, data bases and similar low level issues, but how about they spend three months talking to the losers on the Finder team and explaining to them how to solve this problem properly?



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: BMarsh on Jul 14, '05 06:22:17PM

obviously you need to get hired as a manager on the finder team and show them how it should be fixed.

I am being serious, and only a little sarcastic.

while you are at it, get them to improve the threading related to network activity. (I have submitted feedback with suggestions on possible ways to do this, and have applied for jobs at apple, but so far, neither has happened)



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: chyna4xena on Jun 05, '06 07:35:50PM
As one earlier poster said, creating .DS_Store files is NOT a good thing. It is a stupid pathetic hack, the sort of thing an amateur programmer would come up with. There are a dozen different ways one can imagine the Finder storing the various things it wants to know about how to display a particular directory, all of which don't have this horrible impact on the user.

What absolute rubbish. A dozen different ways ? All of which don't have this impact (or worse) ?

Go on then, name one. Just one !

There are plenty of ways of storing the info, it is just that they ALL have drawbacks. A particular, alternative, method might have a drawback that is not of much bother to you, but it could still be a big problem for other people, and possibly the majority of users.

You are ignoring the possibiity, the likelihood even, that Apple has assessed all the different methods of storing this metadata, and chosen the one that has the least drawbacks, and the least negative impact, for the majority of users. Given the drawbacks of the alternative methods I know of, I'd say it is less a likelihood and more a certainty.

[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: jollyroger on Jul 20, '05 11:18:57AM

On Thu, Jul 14 '05 at 08:30 AM, thoughton wrote:

> Why don't you just try it fer chrissakes. It's not like it will take you more than 5
> seconds to cut and paste the SINGLE command into your terminal window. I've
> heard of hand-holding but this is ridiculous.

Did someone get up on the wrong side of the bed? Get a grip - you'll live longer.

Maybe he *did* try it, and for some reason it didn't work, and rather than assuming it just doesn't work on Panther, figured he'd ask here. I'll go ahead and answer his question in a more polite way, since you seem to be unable to do it:

I can verify that this hint does not appear to work in 10.3.9 for me. I have:

# defaults read com.apple.desktopservices DSDontWriteNetworkStores
true

Yet when I connect to a shared folder (netatalk share on a SuSE Linux machine), Mac OS X still creates .DS_Store folders.

---
-monoclast



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: imit8 on Feb 21, '06 06:41:27PM

> I can verify that this hint does not appear to work in 10.3.9 for me. I have:
>
> # defaults read com.apple.desktopservices DSDontWriteNetworkStores
> true
>
> Yet when I connect to a shared folder (netatalk share on a SuSE Linux machine), Mac OS X still creates .DS_Store folders.

Likewise. I have OS X 10.3.9 and I created com.apple.desktopservices.plist in the system and user preferences folders (/Library/Preferences and ~/Library/Preferences). I rebooted and verified the setting using the command you posted.

Apple's advice simply does not work for me, either. I still get .DS_store files all over the place on the SMB share I use.



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: jacobolus on Dec 06, '05 04:22:17PM

It's the resource fork of the files. It doesn't matter if you're moving them to linux, unless some mac program has added metadata to the resource fork.



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: grahamperrin on Jan 02, '08 01:05:25PM
> It's the resource fork of the files.

That's a common misunderstanding.

.DS_Store is associated with, amongst other things: comments that users add to files, layouts within folders, and so on.

._ files only sometimes relate to resource forks. Another example of ._ files is given at http://www.nabble.com/WebDAV-%28PLIP--187%29-and-Mac-OS-X-td14536481s6745.htm and further examples may exist.

Whilst you may choose to discard comments and other information relating to your _own_ files and folders, it's not good practice to destroy data that may be required by someone else.

Regards
Graham

[ Reply to This | # ]
networked homedirs?
Authored by: viktor24 on Jul 17, '06 08:43:12AM

Can it be that this is not working for networked homedirectories? We have this situation here, and .DS_Store files are still created / modified as before...



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: kalidasa on Aug 02, '06 06:25:59AM

It should be noted that .DS_Store is very similar in purpose to the thumbs.db file on WinXP.



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: Anonymous on Dec 05, '06 12:32:50PM
Wrong.

Thumbnails are stored individually in the resource fork of the file, which is stored as ._filename on non-HFS+, non-AFP volumes. Windows's thumbs.db file only holds thumbnail images for the pictures in that directory.

Maybe the Finder just needs an option to "Store window and icon placement information only on HFS+ and AFP volumes"?

[ Reply to This | # ]

Prevent .DS_Store file creation on network volumes
Authored by: orbii on Jul 30, '09 08:31:39AM

is there a way to resolve this in 10.5.*?



[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: Adain on Jan 05, '10 02:53:42AM
I will read time to time that..... Network Security Software
Edited on Jan 05, '10 02:55:48AM by Adain


[ Reply to This | # ]
Prevent .DS_Store file creation on network volumes
Authored by: Gianna on Sep 18, '10 07:43:17AM

Sorry but I am new to being my own IT person. What is the "terminal" or how do I find it to put in the code?

Gianna



[ Reply to This | # ]