Hi, I wrote an applescript to download a weather map and make it my desktop image. it seems to work fine when I run it standalone.
As a cron job, i get the error that the file can't be found. This error is thrown right after the script downloads the image - I thought that it might be that the script was downloading the picture, the download wasn't finish, and the script kept executing, thus the file wasn't found when the script resizes the picture to fit the desktop.
As a result, I added a delay of 20 seconds (using delay 20 - i hope that is right) after the script downloads, but before I proceed. It still seems very spotty. Again, it works fine when run from script editor or menu, but when run as a cron job.... (osascript /Users/pathto/weather.scpt) Any ideas?
Code:
set myDate to current date
set myTime to time of myDate
set fileTime to ((myTime div 3600 as string) & "-" & ((myTime div 60) - (myTime div 3600) * 60) as string)
--set weather_map to "acttemp_720x486.jpg" -- temperatures
set weather_map to "curwx_720x486.jpg" -- surface isobars
set the target_URL to "http://maps.weather.com/images/maps/current/" & weather_map
set the destination_file to ((path to desktop as string) & "weather-isobars" & "-" & fileTime & ".jpg")
tell application "URL Access Scripting"
download target_URL to file destination_file replacing yes
end tell
delay 20
tell application "Image Events"
set this_image to open destination_file
pad this_image to dimensions {1280, 1024}
save this_image with icon
close this_image
end tell
tell application "Finder"
set desktop picture to destination_file as alias
delete destination_file
end tell