Applescript 下载&打开链接
我在 Apple Mail 中设置了一条规则来运行“下载并打开链接”applescript。我希望这个脚本下载邮件消息中的网址,下载后应该打开该文件。
不知道如何开始。这是不起作用的代码:
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
I've set a rule in Apple Mail to run a "Download & Open link" applescript. I would like this script to download the url in the mail message and after downloading it should open the file.
No idea how to start on this. Here's the code that isn't working:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在尝试将链接下载到字符串中,除非您将字符串强制转换为
别名
,否则这是不可能的。您可以通过以下两种方式之一执行此操作。强制变量
destination_file
初始化为别名...在
在下载链接时强制执行该变量...
完成此操作后,您现在需要做的就是导航到下载文件的文件夹并将其打开。
例子:
You're trying to download the link into a string, which is impossible unless you coerce the string into an
alias
. You could do this one of two ways.Coerce the variable
destination_file
as it's initialized into an alias...Coerce the variable when you're downloading the link...
Once you've done that, all you need to do now is navigate to the folder where you downloaded the file and open it.
Example: