我在Apple Mail中设置了一条规则来运行“下载和打开链接”AppleScript。我希望这个脚本能够在邮件中下载URL,下载后应该打开文件。
不知道如何开始这个。这是不起作用的代码:
using terms from application "Mail"
on perform mail action with messages newMessages
repeat with newMessage in newMessages
tell application "Mail"
set contentLink to (content of newMessage)
end tell
set the destination_file to ("/Users/thomas/Downloads/file")
tell application "URL Access Scripting"
download contentLink to destination_file replacing yes
end tell
end repeat
end perform mail action with messages
end using terms from
答案 0 :(得分:0)
您尝试将链接下载到字符串中,除非您将字符串强制转换为alias
,否则这是不可能的。您可以通过以下两种方式之一完成此任务。
强制变量destination_file
,因为它已初始化为别名......
set the destination_file to "/Users/thomas/Downloads/file/" as POSIX file as alias
在下载链接时强制变量...
download contentLink to destination_file as POSIX file as alias replacing yes
完成后,您现在需要做的就是导航到下载文件的文件夹并打开它。
示例:
tell application "Finder" to open "Macintosh HD:Users:Anonymous:Downloads:example.txt" as alias