Downloading files

-- p1
set theURL to "http://localhost/"
set theFile to path of ("~/Desktop")
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 ""
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")