如何使用 AppleScript 下载文件?

发布于 2024-12-02 09:08:04 字数 325 浏览 0 评论 0原文

例如:

set the file_tgt to (path to downloads as string) as file specification
    set file_src to "http://my_file.png"
    tell application "URL Access Scripting"
        download file_src to file_tgt
    end tell
  1. 如何获取用户默认下载文件夹的路径?
  2. AppleScript 不喜欢路径转换。我该如何解决这个问题?

Something like:

set the file_tgt to (path to downloads as string) as file specification
    set file_src to "http://my_file.png"
    tell application "URL Access Scripting"
        download file_src to file_tgt
    end tell
  1. How do I get the path to the default downloads folder for the user?
  2. AppleScript doesn't like the path conversion. How can I fix that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画▽骨i 2024-12-09 09:08:04

我自己找到了解决方案:

  1. 使用“下载文件夹路径”
  2. 设置 file_tgt to(下载文件夹的路径作为字符串)& “文件.png”

I found the solution myself:

  1. Use "path to downloads folder"
  2. set the file_tgt to (path to downloads folder as string) & "file.png"
甜中书 2024-12-09 09:08:04

使用 applescript 和 shell 脚本下载目录中托管的文件集合 -

set counter to 0
repeat 36 times
    do shell script "curl -f 'http://stage.omatics.com/Images/Devices/Devices/" & counter & ".png' -o ~/Desktop/" & counter & ".png"
    set counter to counter + 10
    delay 2
end repeat

这会将这 36 个文件下载

http://stage.omatics.com/Images/Devices/Devices/0.png
http://stage.omatics.com/Images/Devices/Devices/10.png
http://stage.omatics.com/Images/Devices/Devices/20.png
--
--
http://stage.omatics.com/Images/Devices/Devices/350.png

到您的桌面上。

希望这有帮助。

To download a collection of files hosted in a directory using applescript and shell script -

set counter to 0
repeat 36 times
    do shell script "curl -f 'http://stage.omatics.com/Images/Devices/Devices/" & counter & ".png' -o ~/Desktop/" & counter & ".png"
    set counter to counter + 10
    delay 2
end repeat

This will download these 36 files

http://stage.omatics.com/Images/Devices/Devices/0.png
http://stage.omatics.com/Images/Devices/Devices/10.png
http://stage.omatics.com/Images/Devices/Devices/20.png
--
--
http://stage.omatics.com/Images/Devices/Devices/350.png

at your desktop.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文