I am trying to create a sudo-backup downloader thingy to archive elements of a website on a daily basis to my hard disk. I’ve got just about everything working, except that I am having difficulty creating a folder to store the backup in that reflects the current date. Here’s the majority of my code…
set file_location to "Files:backups:" as string
set the_date to current date
set the_month to month of the_date
set the_day to day of the_date
set folder_name to the_month & " " & the_day as string
set file_path to ((file_location as string) & folder_name & ":") as string
tell application "Finder"
make new folder at file_location with properties {name:"new_folder"}
set file_alias to (file_location & "new_folder:") as alias
set name of file_alias to file_path
end tell
tell application "Fetch 4.0.2"
activate
make new transfer window at beginning with properties {hostname:"****", userid:"****", password:"****"}
open remote item "public_html"
copy remote directory "*****" to beginning of alias file_alias
end tell
Just skip over the bottom tell, as everything I’m doing with fetch works fine. My real problem comes when I try to rename my new_folder. Applescript chokes on it every time.
Any thoughts or suggestions? I do know that my code is a bit, er, sloppy… but I’ve been struggling with this for an hour, and it gets progressively messier as I work.
set file_location to "Files:backups:" as string
set the_date to current date
set the_month to month of the_date
set the_day to day of the_date
set folder_name to "" & the_month & " " & the_day
tell application "Finder"
set new_folder to (make new folder at folder file_location with properties {name:folder_name}) as alias
-- new_folder is now ready for business
end tell
tell application "Fetch 4.0.2"
activate
make new transfer window at beginning with properties {hostname:"****", userid:"****", password:"****"}
open remote item "public_html"
copy remote directory "*****" to beginning of new_folder
end tell
set file_location to "Files:backups:" as string
set the_date to current date
set the_month to month of the_date
set the_day to day of the_date
set folder_name to the_month & " " & the_day as string
set file_path to ((file_location as string) & folder_name & ":") as string
tell application "Finder"
make new folder at file_location with properties {name:"new_folder"}
set file_alias to (file_location & "new_folder:") as alias
set name of file_alias to file_path
end tell
for an even easier date call
example set folder_name to do shell script “date +%m/%d/%y” as string
set file_location to "Files:backups:" as string
set folder_name to do shell script "date +%m/%d/%y" as string
set file_path to ((file_location as string) & folder_name & ":") as string
tell application "Finder"
make new folder at file_location with properties {name:"new_folder"}
set file_alias to (file_location & "new_folder:") as alias
set name of file_alias to file_path
end tell
--returns "07/16/03"
My thanks to both of you fine gentlemen. I have used both suggestions, and the script is humming away. I did run into one minor inconvenience… it appears that I’m downloading too much! :lol:
Actually, what happens is that the script times out due to the length of the download. Is there any way to tell an applescript to ignore timeouts, or give them a really long timeout delay?