2012-05-24 15 views
7

Ho notato che lo strumento 'zip' della riga di comando e l'opzione 'Comprimi XXX' di Mac OS X (disponibile tramite clic destro nel Finder) stanno dando diversi file di output. Non solo le dimensioni del file sono di qualche centinaio di byte in più, ma anche il contenuto è significativamente diverso.Opzione 'compress' per Mac OS X vs riga di comando zip (perché producono risultati diversi?)

Come posso sapere quale comando sta utilizzando il Finder per la compressione?

+0

possibile duplicato di [Come creare un file zip nello stesso formato come voce di menu del Finder "Comprimi"?] (Http://stackoverflow.com/questions/107903/how-to-create-a -zip-file-nello-stesso-formato-come-i-finder-compress-menu-articolo) – ceejayoz

risposta

4

Date un'occhiata a An AppleScript to compress a Finder selection articolo.

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 
16

La risposta è in man ditto:

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

Questa dovrebbe essere la risposta accettata =) –

Problemi correlati