OSX deleting those pesky DS_Store files

If you have a MAC and you have ever transferred anything to USB, then opened the USB Drive on a Linux/Windows machine, you would have noticed the creation of .DS_Store files along with whatever the contents you placed onto the USB.

The .DS_Store files are actually used by OSX to store custom attributes of the folder and the DS_Store is actually an abbreviation, which stands for Desktop Services Store. Anyway, more to the point, how do I get rid of these pesky files. Well the easiest way to do it, is to use the cli and the find command. The syntax to recursively delete these files once you have switched into the correct directory is:

# Change into the USB Directory
cd /Volumes/USB_DIR
find . -type f -name '*.DS_Store' -ls -delete

I actually have created a bash alias so I don’t have to remember the whole command and placed it into my .bash_profile file under my home directory, the alias I use is:

alias cleanDS="find . -type f -name '*.DS_Store' -ls -delete"

A great post that explains the bash_profile file can be found here: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s