http scheduled file transfer

Hello all,

here is what I want to do, any ideas? Anyone scripted something similar in applescript? Anyone know of software that will do this?

So every other day I would like to have an automated script connect to the internet, go to a http directory that contains folders which contain .gif images. I would like the script to then download a set of select .gif’s and put them in a folder structure on my mac and then disconnect from the internet.

Details/issues

  1. the gif’s are weather plots, temperature, precipitation etc… and their individual names do not change.

  2. the gif’s are updated every other day and put into folders whose names change predictably,

The folder names are the dates of the weather plots and they contain suites of images whose names do not change, e.g. temphr1, temphr2…

So every other day a new folder named that days date appears on the site, it is filled with static name .gif’s that I want to download to my computer.

Any suggestions would be greatly appreciated! Sorry for such a long-winded post.

Frank

set imageList to {"machead.gif", "folder_announce.gif", "folder_sticky.gif"}
set DayFolder to "images"
repeat with thisImage in imageList
	tell application "Internet Explorer"
		GetURL "http://bbs.applescript.net/templates/subSilver/" & DayFolder & "/" & thisImage to "TWS-0103:Desktop Folder:Test:" & thisImage
	end tell
end repeat

I just ran and tested this script using Internet Explorer 5.1 running on Mac OS 9.2 and it successfully downloaded the 3 graphics I listed. See below for detail:

-->if you know the static names of the images, define them here as a list
set imageList to {"machead.gif", "folder_announce.gif", "folder_sticky.gif"}
-->these are images housed on Macscripters web-site

-->next, figure out what the name of the folder is today, in this case we are going to stick with the folder 'images' but I will comment some code on how to set your folder up
set DayFolder to "images"
-->or an example to get today's predictable folder name, just an example - you will of course configure for how the actual folder naming convention works
--set theMonth to the month of the (current date)
--set theDay to the day of the (current date)
--set DayFolder to theMonth & "_" & theDay as string


--now repeat with every image in your static image name list
repeat with thisImage in imageList
	tell application "Internet Explorer"
		GetURL "http://bbs.applescript.net/templates/subSilver/" & DayFolder & "/" & thisImage to "Mac HD:Desktop Folder:Test:" & thisImage
	end tell
end repeat

Best,

Mytzlscript,

Thanks so much for the ideas on coding my file transfer protocal! It works very well! I can see how it is going to be extremely useful!

There is one issue that I am stuck on. The Date String naming convention that the folders I am pulling files from is

‘20030124’

Using the code you provided and otherwise I am unable to set “theMonth” to a numerical value, 01, 02, 03, etc… whenever I try to change the month from a string to a number I get errors like, “can’t make January into a number” or “access not allowed”

I can accomplish the same thing through a set of if, else if commands like in the code below, but I am wondering whether there is a simpler way to accomplish the same thing.

set theYear to the year of the (current date)
set theDay to the day of the (current date)
set theMonth to the month of the (current date)
if theMonth is January then
set theMonth to “01”
else if theMonth is February then
set theMonth to “02”
– etc… etc…
end if

set DayFolder to theYear & theMonth & theDay as string

Thanks in advance for your help! (and patience)
This bbs and the members here are fantastic!

Frank

There is probably a way to get what item number of a list of months contains the current month but this is what I came up with. It’s not a whole lot less wordy than your solution but it doesn’t use anything other than Standard Additions:

set MonthList to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
set NumericalList to {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}

set theMonth to the month of the (current date) as string
set itemCheck to ""
set ItemNumber to 0
repeat until theMonth = itemCheck
	set ItemNumber to ItemNumber + 1
	set itemCheck to item ItemNumber of MonthList
end repeat

set MonthNumerical to item ItemNumber of NumericalList

If you aren’t picky about sticking with Standard Additions you could check out
the DateTime OSAX - a great tool for getting date and time in multiple formats.

set DayFolder to DateTime "%Y%m%d"

would pretty much do it.
You can get DateTime here:
http://osaxen.com/datetime.html

Hope this helps,