Throw the .DS_Store in the .Trashes

Say you’re going to do a production run of your company’s entire website(s) on a CD-ROM for distribution to customers who may not have access to the ‘net while on secure networks. Yeah, I know… a pretty specific case. But, also, just say that you’re going to distribute a CD-ROM that will be viewed on [whatever damned OS under the sun], and you’re developing its contents in OS X.

The first step is burning a master CD to provide to the vendor shop, right? They’ll glass master and mould-inject later. But, when you’re preparing that master CD, there are some OS X hidden files that you should delete from it before going ahead with the burn.

Why? Because who knows how other platforms will display the contents of your CD-ROM. Some can be configured to “show hidden files”, and others don’t know that file or directory names starting with a dot are supposed to be “hidden”, as many *nix & BSD systems assume.

First of all, immediately after the blank CD-R is mounted by the OS X filesystem, you should go in and kill the “.Trashes” directory it creates on mount. Open and

cd /Volumes/[volname_you_specified]

… then…

sudo rm -rf .Trashes

… and provide the password when prompted. You must have Admin. privileges to do this.

Next, we have to clean up those .DS_Store files that OS X’s Finder auto-generates when you view a directory [full expl.]. Since you can’t see them in the Finder, you’re stuck in command-line hell cd’ing to every directory in that branch of the filesystem and looking for/deleting those bastards.

You must be thinking: “But, Gary, there’s GOT to be a better way!”

Why… yes there is a better way. It’s called Python, and all OS X boxes come with it by default. The joy.

Use the os.path.walk() function to navigate the directory structure and delete all files named “.DS_Store”. Or, you could use the module I wrote to do specifically that. Source code here. Snag that, edit to your liking in your favorite text editor, open, rename it “” and chmod that fucker to 755.

Then, run it.


3 thoughts on “Throw the .DS_Store in the .Trashes

Comments are closed.