OSX >=10.4 : Prevent .DS_Store file creation on network volumes

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.

 

Now search all .DS_Store and .AppleDesktop files

# find . \( -name \*.DS_Store -o -name \*.AppleDesktop -o -name \*Thumbs.db \)

 

To delete all these files :

# find . \( -name \*.DS_Store -o -name \*.AppleDesktop -o -name \*Thumbs.db \) -exec rm {} \;