I would like my script to copy a specific file every hour into a separate folder, and include the date and time in the filename of the new file created. This is as far as I have been able to get so far:
property repeatTime : 3600
on idle
tell application "Finder"
duplicate file "Macintosh HD:Users:pc:Library:Xplanet:images:clouds_2048.jpg" to folder "Macintosh HD:Users:pc:Library:Xplanet:images:clouds"
end tell
return repeatTime
end idle
Here is the reasoning behind it.
The program Xplanet automatically runs in the background, and every three hours it downloads the clouds_2048.jpg file, overwriting the previous file it has downloaded. I would like to be able to keep a copy of all the cloud files downloaded by Xplanet.
Can anyone help me out, or point me in the right direction.
Thanks
There are quite a few different ways in which you might want to format your date and time, pc - but this might help to get you started:
on stampedName(f)
set tid to text item delimiters
set text item delimiters to "-"
tell (current date) to set d to short date string & space & words of time string
set text item delimiters to tid
set {name:n, name extension:e} to info for f
n's text 1 thru -(2 + (count e)) & space & d & "." & e
end stampedName
on idle
tell application "Finder"
set f to duplicate file "Macintosh HD:Users:pc:Library:Xplanet:images:clouds_2048.jpg" to ¬
folder "Macintosh HD:Users:pc:Library:Xplanet:images:clouds"
set f's name to my stampedName(f as alias)
end tell
3 * hours
end idle