URL Access: Setting download location

I can download a file just fine if I let it download to the top folder level of the startup disk aka the hard drive with out defining a folder location to save the downloaded file to but I do need to do just that. I need to have something like…

tell application "URL Access Scripting"
	set theFile to "http://www.myURL.com/thefile.html"
	set prefPath to (path to preferences as text)
	download theFile to prefPath & "Untitled.txt" replacing yes
end tell

But I get an error

URL Access Scripting got an error: Can’t make some data into the expected type. (-1700)

So How do I define the location to download to?

You’re passing text instead of a file specification. Try this instead:

tell application "URL Access Scripting"
	set sourceURL to "http://www.myURL.com/thefile.html"
	set outputFile to ((path to preferences as Unicode text) & "Untitled.txt") as file specification
	download sourceURL to outputFile replacing yes
end tell

oh sweet. thanx. :slight_smile: