Terminal Can';t使用AppleScript解压文件
我正在尝试制作一个AppleScript,它使用变量将文件下载到下载文件夹Terminal Can';t使用AppleScript解压文件,terminal,applescript,directory,unzip,minecraft,Terminal,Applescript,Directory,Unzip,Minecraft,我正在尝试制作一个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 然
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
尝试:
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