Synchronize Folders at Shutdown (problem...)
Synchronize Folders at Shutdown (problem...)
- Subject: Synchronize Folders at Shutdown (problem...)
- From: chris stearns <email@hidden>
- Date: Thu, 07 Dec 2000 01:48:54 -0800
Hi Scripters,
I'm a rank newbie at AppleScript, and I've attempted to modify Apple's
"Synchronize Folders" script to backup my Microsoft Users Data folder when I
shut down the machine.
I've specified the folders to use and saved the script as an applet (if I
save it as a 'compiled script,' when it's run, it just opens Script
Editor... Is this what I'm doing wrong?). Then I put it in the "Shutdown
Items" folder. When I shut down or reboot, he backup seems to work just
fine, copies files etc., but after it's done..... Nothing. The machine
does not shut down. If I select Shut Down or Restart AGAIN, the machine will
do just that - without running the Sync Folders script again.
I've searched the Online Help and the Guidebook, but can't seem to find
anything useful. I know I'm missing something really simple here, can anyone
steer me back on track?
I've included a copy of the script, since it isn't too long:
on run
tell application "Finder"
activate
try
set folder1 to "Macintosh HD:Documents:Microsoft User
Data:"
on error -- e.g. user cancelled
return
end try
try
set folder2 to "Macintosh HD:Documents:The Heap:office-mac Data
Backup:"
on error -- e.g. user cancelled
return
end try
SyncFolders(folder1, folder2) of me
end tell
end run
on open x
tell application "Finder"
set ErrorString to "Syncronization process needs 2 folders. " & ,
"Please try again with 2 folders."
if (count items in x) 2 then
display dialog ErrorString buttons "OK" default button 1
return
end if
set y to item 1 of x
if last character of (y as text) is ":" then --it's a folder
set x to item 2 of x
if last character of (x as text) is ":" then --it's a folder
SyncFolders(x, y) of me
else
display dialog ErrorString buttons "OK" default button 1
end if
else
display dialog ErrorString buttons "OK" default button 1
end if
end tell
end open
on SyncFolders(folder1, folder2)
SyncEm(folder1, folder2)
SyncEm(folder2, folder1)
end SyncFolders
on SyncEm(folder1, folder2)
tell application "Finder"
set Folder1Contents to list folder folder1
set Folder2Contents to list folder folder2
repeat with x in Folder1Contents
if x is not in Folder2Contents then
duplicate alias ((folder1 as text) & x) to folder folder2
else
if kind of alias ((folder1 as text) & x) is "folder" then
SyncFolders(((folder1 as text) & x) as alias, ((folder2
as text) & x) as alias) of me
else
set date1 to modification date of alias ((folder1 as
text) & x)
set date2 to modification date of alias ((folder2 as
text) & x)
if date1 > date2 then
duplicate alias ((folder1 as text) & x) to folder
folder2 with replacing
end if
end if
end if
end repeat
end tell
end SyncEm
Thanks in advance,
--
Chris Stearns
Editor, The Mezzanine Reader
http://www.mezzaninereader.com