0

我正在尝试制作一个使用变量将文件下载到下载文件夹的 AppleScript

set downboadFolder to (path to downloads folder) & "Technic-Launcher-OSX.zip" as text
set downloadFolder to downboadFolder as alias
#I downloaded Technic-Launcher-OSX.zip earlier in the code and that works

然后我使用这段代码

tell application "Finder"
    try
        move downloadFolder to targetFolder
    end try
end tell

将文件移动到目标文件夹

try
  set targetFolder to (choose folder)
end try

我用这个完成了代码。

set targetFoldera to targetFolder & "Technic-Launcher-OSX.zip" as text
set targetFolderb to targetFoldera as alias
do shell script "/usr/bin/unzip -d /" & (targetFolder) & " " & targetFolderb

这应该将 foldera 设置为 /thefoldertheychoose/TechnicLaunchesOSX.zip 然后将 folderb 设置为 foldera 作为别名然后将文件解压缩到他们选择的文件夹当我运行它时,我得到了这个

unzip:  cannot find or open HD:Users:username:Documents:,     HD:Users:myusername:Documents:.zip or HD:Users:usnername:Documents:.ZIP." number 9
#I chose Documents as the folder
4

1 回答 1

0

尝试 :

set downboadFolder to (path to downloads folder as text) & "Technic-Launcher-OSX.zip"
set targetFolder to (choose folder)
tell application "Finder" to set targetFile to move downboadFolder to targetFolder
set {targetFile, targetFolder} to {(targetFile as alias)'s POSIX path, targetFolder's POSIX path}
do shell script "cd " & quoted form of targetFolder & " ; /usr/bin/unzip " & quoted form of targetFile
于 2012-10-22T12:11:02.847 回答