.DS_Store files are created by OS X to store information relevant to the Finder, such as window positioning, and Finder comments. For the majority of users they go completely unnoticed because by default they are invisible, as are all other files beginning with a period. The easiest way to see them is to pop open the terminal and type in "ls -la ~". What you’ll see are a list of all the files in your home directory, including the invisible ones.
So why care about the .DS_Store file? They are insignificantly small, hidden, and help the Finder out. That is, unless you’re operating in an environment with PCs, or accessing files from a Mac over and FTP client. Then they can become rather obvious and very confusing.
There are a bunch of little applications that can remove .DS_Store files, among other things, but who wants to download an application for something that can be done with a really simple command. Most of the commands I’ve seen involve find executing rm followed by a few other arguments. For the life of me I can’t understand why people aren’t just using the “-delete” argument in find.
Here is my simplified rendition:
find . -name .DS_Store -delete
Yes folks, it’s that simple. find is a Unix tool for locating files. The period is the path to start at. I could have used “/” if I wanted it to start at the root of the drive. Period means start from my current location in the Terminal (usually represented to left of where you start typing in the Terminal). The “-name” tells find what to look for, in this case the pesky .DS_Store file. Lastly -delete tells find to remove the file when it encounters it. Remember that you might have to use the sudo command depending where you want to remove them from.
A word of caution, this command permanently removes the .DS_Store files. It doesn’t move them to the trash. The Finder will replace the .DS_Store files when it needs to. As with any Unix command, please type carefully and fully understand what is going on, before you hit return. There are no “undos,” that’s why it’s a great idea to backup your computer. While this command, when used right should be harmless, backing up could save you from the mess you get into from someone else’s Unix trick, or enabler. I hope I haven’t scared anyone.