How to Prevent .DS_Store File Creation
.DS_Store files store folder level metadata information (such as icon placement and background pictures) for Mac OS X to understand, this is fine and dandy and you’re likely to never even notice if you’re a bunch of Macs working together. Unfortunately, these .DS_Store files can be really pesky in a multi-platform network environment, they can basically just lead to unnecessary filesystem clutter that Windows & Linux users receive no benefit from.
Thankfully, you can prevent the DS_Store files from being created entirely by executing a simple command in the Terminal.
How to Stop DS_Store File Creation on Network Volumes in Mac OS X
To disable the creation of .ds_store files, launch the Terminal application from /Applications/Utilities/ and enter the following command string exactly:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Reboot the Mac for changes to take full effect (some report that killing the Finder is sufficient, but your mileage may vary).
This disables the creation of .DS_Store files for the user account the command was executed on. You can make this change to all user accounts manually by executing the same command under their login, or you can copy modified com.apple.desktopservices.plist file to the ~/Library/Preferences folder of each other user account.
Of course it’s not just Mac OS X that create files that are obnoxious for cross-platformers. The Windows equivalent to the DS_Store file is Thumbs.db, and if you’re a Mac in a largely Windows network, you’ll probably be running into these all the time. You can easily delete Thumbs.db files in Mac OS X by using Spotlight.
Enable DS_Store File Creation on Network Volumes
To re-enable the creation of .ds_store files, simply change the ‘true’ to ‘false’ in the defaults command string:
defaults write com.apple.desktopservices DSDontWriteNetworkStores false
You will want to reboot the Mac and reconnect network shares for the changes to take full effect.
This works in all versions of Mac OS X, from OS X El Capitan, OS X Mavericks to Mac OS X Snow Leopard. You can learn more about DS_Store files here.