我正在尝试制作一个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
答案 0 :(得分: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