Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there anyway to get rid of the .DS_Store when compressing a folder on a mac?

I work on a mac and send work to clients in zip format, but always get questioned on the .DS_Store folder inside them. It seems to be unavoidable unless I open the folder on Windows then delete the .DS_Store and compress it there. It is quite a big hassle.

Are there any easy work arounds?

share|improve this question
up vote 68 down vote accepted

If you do not mind jumping down in to terminal, then this is pretty darn easy. If you are in /Users/username, which is your $HOME directory and there is a subdirectory named foo that you want to zip but ignore all .DS_Store files, then do the following:

zip -r foo -x "*.DS_Store"

To interpret this, we are running the zip executable with the following parameters/arguments:

  • -r for recursively including all directories underneath the targets we want to zip.
  • is the name of the zip archive we are creating
  • foo is the target directory we want to zip up
  • -x "*.DS_Store" excludes all files whose path ends in the string ".DS_Store"

No goofy third party applications needed nor do you need to trash your .DS_Store files at all - just rely on all of the unix tool goodness built right in to OSX / Darwin.

share|improve this answer
This is perfect thanks. Out of interest, how would I exclude multi path endings? Something like zip -r foo -x "*.DS_Store, *.svn" ? – danixd Oct 12 '10 at 14:10
Use the -x argument twice: zip -r foo -x *.DS_Store -x *.svn* – whaley Oct 12 '10 at 14:50
How do you exclude the Icon-files OSX creates for custom folder icons? They have a newline or something like that at the end of the filename. – Daniel Beck Oct 12 '10 at 17:42
I have no clue what those filenames look like so I can't give any real guidance here. – whaley Oct 12 '10 at 18:36
ls says Icon?, but I think it's ASCII 0x0A at the end. If you have an OS X system, copy & paste an icon from one file info dialog to another (select the icon on the top left and Cmd-C, then on a folder info dialog the same with Cmd-V). Then the file is created within the folder. – Daniel Beck Oct 13 '10 at 10:54

I don't think there's a way to do it by default, but there's two ways I can think of to achieve what you want.

First off, I found a free app called FolderWasher. Drop the folder on the app and it'll remove the .DS_Store files and zip it for you.

Alternatively (and potentially better than 3rd party software) you can use Automator to clean the archive after creation. There is actually already an action created for this. That's only one extra step, and you can drag the action to Finder so it's easy to find.

share|improve this answer

Use CleanArchiver to create those archives. This way you don't need to trash your folder preferences.

share|improve this answer

There is an explanation of what they are, and how to delete them on the adobe help site of all places.

They are a hidden file used to store the configuration of a folder (like icon position, color, folder background and scroll position. Unfortunately there seems to be no way to stop them being created permanently, although apple do admit that they can cause problems for some users.

share|improve this answer

Open Terminal (/Applications/Utilies/ and run the following command to show hidden files:

defaults write AppleShowAllFiles TRUE && killall Finder

To hide the hidden files simply run:

defaults write AppleShowAllFiles FALSE && killall Finder

You can delete .DS_Store files just like any other files without causing any harm to your directory. As stated on wikipedia, "DS_Store (Desktop Services Store) is a hidden file created by Apple Inc.'s Mac OS X operating system to store custom attributes of a folder such as the position of icons or the choice of a background image."

share|improve this answer

If you've already created the zip archive (or want a simple way of removing .DS_Store post zip creation), this will remove all .DS_Store files at any path in the zip archive:

zip -d "*/*.DS_Store"

whaley's answer is still definitely the best, because it can be aliased and forgotten about. In my case, I created the zip from the Archive Utility, then realized I should delete these.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .