14

コマンド ラインの 'zip' ツールと Mac OS X の 'Compress XXX' オプション (ファインダーで右クリックして利用可能) が異なる出力ファイルを生成していることに気付きました。ファイルのサイズが数百バイト大きくなるだけでなく、内容も大きく異なります。

Finder が圧縮に使用しているコマンドを確認するにはどうすればよいですか?

4

2 に答える 2

24

答えは次の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.
于 2012-05-24T16:24:04.107 に答える
3

Finder 選択記事を圧縮するための AppleScript をご覧ください。

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
于 2012-05-25T06:44:39.657 に答える