在applescript中压缩文件夹时出错

时间:2016-11-30 03:48:39

标签: zip applescript

我正在尝试开发一个自动脚本来压缩文件夹,但我一直收到以下错误:

error "Finder got an error: 
zip error: Nothing to do! (/Users/dam/Desktop/Design/_TEST/basefolder/Fonts.zip)" number 12

一直在搜索论坛,并没有完全达到标记。任何帮助的菜鸟将不胜感激。谢谢!

tell application "Finder"
    set projFonts to (choose folder with prompt "Please select font folder.")
    set fontPath to quoted form of POSIX path of projFonts
    set zipName to the name of projFonts
    set theFolder to POSIX path of (container of projFonts as alias)
    set zipFile to the quoted form of (theFolder & zipName)
    do shell script "zip -j " & zipFile & " " & fontPath
end tell

1 个答案:

答案 0 :(得分:0)

我认为这就是你想要的,虽然这个问题缺乏细节。

set theItem to (choose folder)
tell application "Finder" to set {fileName, theFolder} to {theItem's name, (theItem's container as text)'s POSIX path}
do shell script "zip -rj " & (theFolder & fileName & ".zip")'s quoted form & space & theItem's POSIX path's quoted form