4
votes

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?
2

2 Answers

2
votes

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"
0
votes

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.