n00b needs help with a script to save a web image

so i would like an applescript that will automatically save a specific web image ever 5 minutes. i figured out how to make it save the image, but i don’t know how to set the correct destination folder for the saved image or how to get the script to repeat every 5 minutes. the image comes from a web cam that also has a 5 minute refresh time. please help, i’m a new mac user and would like to get this tool to work for me.

FateCreatr :smiley:

If the folder doesn’t change, you can just specify the folder to download the file to. Here’s an example, say, if you want to get the volcano cam for Mt. St. Helens : :wink:

set destFolder to POSIX path of (alias "MacHardDrive:Users:username:Pictures:")
set curlCommand to ¬
"curl http://www.fs.fed.us/gpnf/volcanocams/msh/images/mshvolcanocam.jpg -o " & destFolder & "mshvolcanocam.jpg"
do shell script curlCommand

Use an idle handler for the time. Check here for info.

on idle
<do your script stuff here>
return 300 --return is in seconds, 5 minutes x 60 second per min. equals 300
end idle

If you need any explanations, ask.

thank you, that is exactly what i was looking to do. after putting up that post i started opening the applescript examples that are on my machine here, and i put something together that seems to work ok. i don’t understand what some of it means, and i’m just guessing at the rest, and this is my first time using applescript, but what i came up with is below.

set the target_URL to “http://www.fs.fed.us/gpnf/volcanocams/msh/images/mshvolcanocam.jpg
set the date_stamp to ((the current date) as string)
set the destination_file to ((path to desktop as string) & “st_helens/sthelens.jpg”)

repeat
tell application “URL Access Scripting”
download target_URL to file destination_file replacing no
end tell
delay 300.0
end repeat

i think yours looks better though. thank you again.

FateCreatr

I wouldn’t use the delay, I think it stops all processes. The idle handler just polls the clock every second.
There is one big glaring error in my answer, though. Well, maybe not glaring, but it is big…
You have to save the script as a “stay open” applet.

Searching around the site here, I found this post which is almost exactly what you want. Trust Jonn8 to have the answer, he always seems to. Look as Jonn8’s second answer and the script near the end.

As for steal^H^H^H^H^Hborrowing other scripts and adapting them to you own uses, that’s just a long and hallowed tradition of AppleScript. :slight_smile: