Ask Different is a question and answer site for power users of Apple hardware and software. 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

In Finder, when I create an archive ("Compress items..."), the resulting zip archive has .DS_Store files in folders and files have resource forks. How can I create a zip archive suitable for cross platform sharing from Mac OS X?

share|improve this question
up vote 3 down vote accepted
  • zip -r -x .DS_Store directory
    • zip removes extended attributes and ACLs by default
  • find directory -name .DS_Store -delete; ditto -ck --norsrc directory
    • --norsrc implies --noextattr and --noacl; --noextattr would require --norsrc
    • -c is compress, -k uses PKZip (zip) instead of CPIO
  • COPYFILE_DISABLE= tar --exclude .DS_Store -czf directory.tgz directory
    • Setting COPYFILE_DISABLE tells tar to remove extended attributes and ACLs instead of creating ._ files

The files that start with ._ are AppleDouble files (not resource forks), and they are used to store extended attributes and ACLs.

Extended attributes are used to store the quarantine status of files, the source URLs of files downloaded from the Internet, information about aliases (aliases stop working if extended attributes are removed), Spotlight comments, the encoding of files saved with TextEdit, and so on.

You can list extended attributes and ACLs with ls -l@e. You can remove extended attributes and ACLs recursively with xattr -cr .; chmod -NR .

share|improve this answer

You can use the ditto command.

ditto -ck --norsrc sourcedir

-c create an archive
-k create a PKZip archive instead of the default, which is CPIO
--norsrc do not preserve the resource forks

I think this will still include .DS_Store files, though.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.