Apple - Why does a .DS_Store file keep appearing on the desktop?

Type this in Terminal (/Applications/Utilities/Terminal.app):

defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder

The first command sets the hidden files visibility to hidden; the second one forces Finder to restart. This is needed for the first command to take effect.

You can also log out/reboot instead of killing the Finder, but the first command is needed to change a hidden preference (one that the Finder can’t change using the normal Finder view options or preferences).


There's a way to hide all "dot" files from Desktop with 3rd party app called XtraFinder.

Go to Settings → Features tab → Hide dot files on Desktop

Screenshot of XtraFinder

Though I still didn't manage to hide all .DS_Store files and keep all other dot files visible, this is a pleasant improvement.


.DS_Store is used by OS X to store directory information used by Finder such as icon position, etc.

In OS X any file name that starts with a "." is hidden, so to hide the .DS_Store file you can use the terminal command:

sudo defaults write com.apple.finder AppleShowAllFiles NO

Basically, you can ignore it. If you are copying a directory to a flash drive and looking at it in Windows, feel free to just delete it. It is Mac OS X Finder that creates this file whenever it opens a new directory.

An alternative solution would be to prevent Finder from automatically creating these files. The following terminal command changes the default setting from automatically creating them to not:

defaults write com.apple.desktopservices DSDontWriteNetworkStores TRUE

And to revert back to the default behavior:

defaults delete com.apple.desktopservices DSDontWriteNetworkStores