Mac OS X 'compress' option vs zip command line (why do they give different results?)

I noticed that the command-line tool "zip" and the Mac OS X option "Compress XXX" (available by right-clicking in finder) provide different output files. Not only is the file size a few hundred bytes larger, but the content is also significantly different.

How do I know which Finder command to use for compression?

+7
source share
2 answers

Take a look at AppleScript to compress the Finder selection .

try tell application "Finder" set theSelection to the selection set selectionCount to count of theSelection if selectionCount is greater than 1 then error "Please select only one Finder item before running this script." else if selectionCount is less than 1 then error "Please select one Finder item before running this script." else set theItem to (item 1 of theSelection) as alias set destFolder to (container of theItem) as alias set itemName to name of theItem end if end tell do shell script ("ditto -c -k --sequesterRsrc --keepParent " & quoted form of POSIX path of theItem & space & quoted form of (POSIX path of destFolder & itemName & ".zip")) on error theError tell me activate display dialog "Error: " & theError buttons {"OK"} default button 1 with icon stop end tell end try 
+4
source

The answer is in man ditto :

  The command: ditto -c -k --sequesterRsrc --keepParent src_directory archive.zip will create a PKZip archive similarly to the Finder Compress function- ality. 
+16
source

All Articles