Help Modifying Script

I’m trying to modify Apple’s ‘Synchronize Folders’ script so it will automatically synch to files without presenting the ‘Choose File’ dialogue. I thought I could do this fairly easily by inserting the actual folder names (Folder A, Folder B) and removing the ‘Choose’ segment.

However I keep getting an error at the duplicate alias stage. Any help appreciated.Script follows:

on run
tell application "Finder"
activate
try
set folder1 to choose folder with prompt "Select the first folder:"
on error -- e.g. user cancelled
return
end try
try
set folder2 to choose folder with prompt "Select the second folder:"
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."i
f (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
elsei
f 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

The call to the subroutine:

on SyncFolders(folder1, folder2)
SyncEm(folder1, folder2)
SyncEm(folder2, folder1)
end SyncFolders

needs the path names (not names) of two folders; e.g., not my SyncFolder (“Folder A”, “Folder B”) but the fully-qualified path names:

SyncFolder ("HD:Folders:Folder A","HD:Folders:Folder A")

which must exist, so watch for typos.
macguy

You could use the script as a droplet and drop 2 files
(instead of folders) on it… but you’d have to copy
the lines concerning the modification dates, into the
on open x function… for example

on open x
..snipped..
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 ErrorMessage
end if
else
--assume both are files...relace the errorMessage stuff..
set date1 to modification date of info for alias (y)
set x to item 2 of x
set date2 to modification date of info for alias (x)
if date1 > date2 then
duplicate alias (y) to alias (x) with replacing
...snipped..

Ed