I am able to get all the data in the test folder to transfer over to my backup in OSX. The problem I am running into is it will not work on OS 9. I put a large delay at the begining so the app would run every twelve hours. I would also like to have the data that is transfered in the backup folder to create a folder with the current date. If anyone could help me out with this I would greatly appreciate it. Thank You.
AppleScript—>
on idle
delay 43200
mount volume “afp://UsrName:password@path/SCH”
delay 10
set localFolder to “test:”
set remoteFolder to “SCH:backup”
tell application "Finder"
duplicate every file of folder localFolder to folder remoteFolder with replacing
eject "SCH"
delay 900
end tell
return 5
end idle
---->
I also need some help creating a folder on the server in the backup folder with the current date as the foldername to transfer the data into. Thank You.
You don’t need the huge delay at the beginning of the ‘idle’ handler. The ‘return’ statement at the end should tell the operating system how many seconds to wait before calling the idle handler again.
What I’ve found using your script in OS 8.6 is:
- You need to supply the full path to the “test” folder, which is presumably on your local desktop.
- ‘Duplicate … with replacing’ moves the old items on the server to the trash of the machine running the script - though this doesn’t mean that the files have been physically moved between machines. The server disk can’t be put away until the trashed files (on the server) are removed from the trash (of the script machine). Mind you, if you’re going to be creating a new folder for each backup, ‘with replacing’ and its attendant problems simply won’t occur.
- The Finder needs to be the frontmost application while this is happening to ensure that everything gets done in the right order.
- In OS 8/9, it’s better to use the Finder’s old ‘put away’ command here rather than ‘eject’.
This works for me and will probably work in OS 9 too:
on idle
mount volume "afp://UsrName:password@path/SCH"
set frontApp to (path to frontmost application as string)
set localFolder to (path to desktop as string) & "test:"
set remoteFolder to "SCH:backup:"
set newFolderName to getTimeStamp()
tell application "Finder"
activate -- bring the Finder to the front
make new folder at folder remoteFolder with properties {name:newFolderName}
duplicate every file of folder localFolder to folder newFolderName of folder remoteFolder -- with replacing
-- activate
-- empty trash
put away disk "SCH"
end tell
-- Return the formerly frontmost app to the front.
-- All applications should obey the 'activate' command, though a few don't....
tell application frontApp to activate
return 12 * hours -- do it again in 12 hours' time
end idle
on getTimeStamp()
set now to (current date)
set {day:d, year:y, time:t} to now
-- Calculate the month number.
copy now to b
set b's month to January
set m to (b - 2500000 - now) div -2500000
-- Short date in yyyy-mm-dd format.
tell (y * 10000 + m * 100 + d) as string
set dateString to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7 thru 8
end tell
-- Time in hh.mm.ss format.
tell (1000000 + t div hours * 10000 + t mod hours div minutes * 100 + t mod minutes) as string
set dateString to dateString & " " & text 2 thru 3 & "." & text 4 thru 5 & "." & text 6 thru 7
end tell
return dateString
end getTimeStamp
Thank you Nigel, This is the second time you have helped me out! Im looking forward to learning more applescript as time goes on, and I really appreciate your help and patients as I Iearn.
Jeff
Hi there,
I’m trying to incorporate this last script into a script of my own - the “on get TimeStamp()” portion of it:
on getTimeStamp()
set now to (current date)
set {day:d, year:y, time:t} to now
-- Calculate the month number.
copy now to b
set b's month to January
set m to (b - 2500000 - now) div -2500000
-- Short date in yyyy-mm-dd format.
tell (y * 10000 * m * 100 + d) as string
set dateString to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7 thru 8
end tell
-- Time in hh.mm.ss format.
tell (1000000 + t div hours * 10000 + t mod hours div minutes * 100 + t mod minutes) as string
set dateString to dateString & " " & text 2 thru 3 & "." & text 4 thru 5 & "." & text 6 thru 7
end tell
return dateString
end getTimeStamp
It works fine except the date comes out totally wrong. The time is correct though, it looks like this:
6.02-10-00 11.11.40
Any help would be much appreciated,
Thanks
Ryan
There’s a mistake in the short date string calculation. It should read:
-- Short date in yyyy-mm-dd format.
tell (y * 10000 + m * 100 + d) as string -- note the "+" sign between 10000 and "m"
set dateString to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7 thru 8
end tell
THANK YOU!!
Works perfect - I’m a bit of a newbie to applescript, so I spent a good hour or so scratching my head on that one.
Ryan
Oops! My humble apologies. I’ve now corrected that in my own post above.
How embarrassing to think that’s been there for over two years. :rolleyes:
I wonder if Stud3233 noticed?