2012-05-24 3 views
7

Ich bemerkte, dass die Befehlszeile 'Zip' Tool und Mac OS X 'Compress XXX' Option (verfügbar über Rechtsklick im Finder) geben verschiedene Ausgabedateien. Die Größe der Datei ist nicht nur ein paar hundert Byte größer, sondern auch der Inhalt ist deutlich anders.Mac OS X 'Komprimieren' Option vs Kommandozeilen-Zip (Warum produzieren sie unterschiedliche Ergebnisse?)

Wie kann ich herausfinden, welchen Befehl der Finder zur Komprimierung verwendet?

+0

möglich Duplikat [Wie eine Zip-Datei im selben Format wie der „Compress“ Menüpunkt des Finders erstellen?] (Http://stackoverflow.com/questions/107903/how-to-create-a -zip-datei-im-selben-format-wie-finders-compress-menu-item) – ceejayoz

Antwort

4

Werfen Sie einen Blick auf An AppleScript to compress a Finder selection Artikel.

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

Die Antwort ist 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

Dies sollte die akzeptierte Antwort sein =) –