我注意到命令行 'zip' 工具和 Mac OS X 的 'Compress XXX' 选项(可通过在查找器中右键单击获得)提供不同的输出文件。文件的大小不仅大了几百字节,而且内容也大不相同。
如何找出 Finder 用于压缩的命令?
我注意到命令行 'zip' 工具和 Mac OS X 的 'Compress XXX' 选项(可通过在查找器中右键单击获得)提供不同的输出文件。文件的大小不仅大了几百字节,而且内容也大不相同。
如何找出 Finder 用于压缩的命令?
答案在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.
查看An AppleScript 以压缩 Finder 选择文章。
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