2012-05-24 14 views
7

Me di cuenta de que la línea de comando 'zip' y la opción 'Comprimir XXX' de Mac OS X (disponible haciendo clic derecho en el buscador) están dando diferentes archivos de salida. No solo el tamaño del archivo es unos cientos de bytes mayor, sino que el contenido también es significativamente diferente.Opción 'compresión' Mac OS X vs línea de comando zip (¿por qué producen resultados diferentes?)

¿Cómo puedo saber qué comando está usando el Buscador para la compresión?

+0

posible duplicado de [Cómo crear un archivo zip en el mismo formato que el elemento de menú del Finder "Comprimir"?] (Http://stackoverflow.com/questions/107903/how-to-create-a -zip-file-in-the-same-format-as-the-finders-compress-menu-item) – ceejayoz

Respuesta

4

Tome un vistazo a An AppleScript to compress a Finder selection artículo.

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 respuesta está en 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

Esta debería ser la respuesta aceptada =) –

Cuestiones relacionadas