Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I used to be able to download URLs from an Applescript, but I lost the Applescript. I want to enter a URL: i.e.: "http://wpclassic.com/go.php?http://www.revolutiontwo.com/download/tv.zip" and have it prompt for a place to put the file.

share|improve this question
    
Related: apple.stackexchange.com/questions/18487/… –  ghoppe Aug 8 '11 at 20:54
    
@ghoppe Sort of, but I'm using SL. –  daviesgeek Sep 17 '11 at 15:44
add comment

1 Answer

up vote 5 down vote accepted
set the URLs to the text returned of (display dialog "Enter the URLs you would like to download. If you have more than one, separate them with commas please:" default answer "")
set the destination to (choose folder with prompt "Choose the folder you want to download the URLs to:")
set AppleScript's text item delimiters to ","
repeat with this_URL in the URLs
    tell application "URL Access Scripting" to download this_URL to the destination with progress and unpacking
end repeat
set AppleScript's text item delimiters to ""

If you are using Lion, the above code won't work (Apple removed URL Access Scripting for some reason). Use the shell command curl instead, as shown below:

set the URLs to the text returned of (display dialog "Enter the URLs you would like to download. If you have more than one, separate them with commas please:" default answer "")
set the destination to (choose folder with prompt "Choose the folder you want to download the URLs to:")
set AppleScript's text item delimiters to ","
repeat with this_URL in the URLs
      do shell script "curl -L " & this_URL & " -o " & POSIX path of the destination 
end repeat
set AppleScript's text item delimiters to ""
share|improve this answer
    
Just so you know...there should be a parenthese on the first line after "default answer""". –  daviesgeek Aug 10 '11 at 16:57
    
@daviesgeek Wow did not see that. Thanks I will fix it. :) –  fireshadow52 Aug 10 '11 at 20:46
    
You are very welcome. –  daviesgeek Aug 10 '11 at 21:27
    
AppleScript Editor gives me: error "URL Access Scripting got an error: Unsupported scheme" number -30774 –  daviesgeek Sep 6 '11 at 15:50
    
I think this worked. I will have to check to see if it did. –  daviesgeek Jan 25 '12 at 19:17
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.