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?
MacOS Finder Archive – Create a Zip Archive for Windows and Linux Users
archivefindermacos
Related Question
- MacOS – How to retrieve image files from a damaged zip archive file
- Compressed archive in Lion creates a root-level “Archive” folder in .zip file
- MacOS – How to label text files as such in zip archive
- How to reset the ‘get info’ preview image of archive utility
- MacOS, Finder, Applescript, Automator, Archive – Compressing Multiple Folders into Individual Zip Files
- MacOS Folders – Compress without .DS_Store and __MACOSX
- MacOS Zip – Create Zip for Windows Without __MACOSX or Hidden Folders
Best Answer
zip -r -x .DS_Store directory.zip directory
zip
removes extended attributes and ACLs by defaultfind directory -name .DS_Store -delete; ditto -ck --norsrc directory directory.zip
--norsrc
implies--noextattr
and--noacl
;--noextattr
would require--norsrc
-c
is compress,-k
uses PKZip (zip) instead of CPIOCOPYFILE_DISABLE= tar --exclude .DS_Store -czf directory.tgz directory
COPYFILE_DISABLE
tellstar
to remove extended attributes and ACLs instead of creating._
filesThe 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 withxattr -cr .; chmod -NR .