Downloading files

-- p1
set theURL to "http://localhost/zippy.zip"
--p2
set theFile to path of ("~/Desktop")
--3
tell application "URL Access Scripting"
	download theURL to theFile
end tell
display dialog "Your download is complete"

I want to be able to choose where to download the file to. (In this case at the desktop.)

Hi slacker,

As long as I am scripting the Mac, URL Access Scripting was always somehow unreliable and I never really got it to work with my own scripts. This is why I suggest to use curl instead:


set theURL to "http://macscripter.net/ads_horiz/images/prmac_banner.gif"
set filepath to quoted form of POSIX path of (((path to desktop) as Unicode text) & "banner.gif")
set command to "curl " & theURL & " -o " & filepath
set output to do shell script command
if output is "" then
	display dialog "Download ok!"
end if

thanks :slight_smile:
would you happen to know how to make a progress bar with this?

It’s not easy :smiley:

==> Curl, Applescript and Progress Bar
==> BP Progress Bar 1.0 by Bruce Phillips (Demo by Adam Bell)

You’re getting an alias and coercing it to a string; Get a string directly instead:

((path to desktop as Unicode text) & "banner.gif")