A lot of people want to know what is the .DS_Store file on a Mac and what is its true purpose? These files appear when hidden files are made visible. Here is my explanation of what the .DS_Store files are and what happens when you delete them and a way to disable them.
What is the .DS_Store file?
The DS_Store files are a proprietary file created by Apple that hold specific metadata information. Every time the Finder application accesses a folder, even network volumes or external devices, you will see the DS_Store file. The metadata that is stored in the DS_Store file consist of are folder level customizations like custom icons, icon placement, icon size, window placement, list views, custom background pictures or colors and more. Since the DS_Store file has a period in front of it, this tells UNIX file systems to keep this file invisible. The design of the file was mainly to be unobtrusive, that is why it is hidden.
What happens if I delete the .DS_Store files?
Deleting a .DS_Store file from a folder on your Mac will result in lost of that specific folders metadata. Icons, icon sizes, list views and other metadata will be lost when you delete the DS_Store file. Besides losing that metadata, there is really no harm in deleting them. Unless you think they are annoying, you should leave the DS_Store files alone. The only time to really delete the .DS_Store file is if you are sharing data on a Windows network. Or you are sending directories, or FTPing folders, to another location.
Another thing to remember is that every time you delete a .DS_Store file, Mac OS X will recreate the file.
Can I Stop the .DS_Store Files?
There is a way to stop Mac OS X from creating .DS_Store files. Even though they do you no harm if you keep them locally. Just execute the following command below in the Terminal. This will prevent the creation of .DS_Store Files.
defaults write com.apple.desktopservices DSDontWriteNetworkStores true