Coding: ChronoSync and Applescript

Friday, 15 September 2006

I use ChronoSync a lot to keep project folders on my machines in sync and too back up work stuff onto other drives, etc.  It’s a really handy little bit of software.  A while back I’d noticed that it was applescriptable & thought I could create a folder action script to attach to my eBooks folder, to have ChronoSync back up the folder to my file server whenever I download a new book.


Sounded straight forward enough, except I don’t really know applescript well, and it turns out that there is no documentation of scripting ChronoSync on the developer’s site, and I couldn’t find any example scripts on the web.  I Ended up submitting a query about it to the developer’s site and got a nice reply back with an example script.


So, anyway, I got my folder action script written and working, and thought I would post it, so that there actually is an example on the web, should anyone else be looking :-)



on adding folder items to this_folder after receiving these_items


        tell application "ChronoSync"


            open alias "Macintosh HD:Users:jimmcgowan:Documents:Syncs:eBookBackup.sync"

            tell document 1 to Synchronize


            --hold on 'till the sync is complete

            repeat while syncStatus of document 1 is not 0

            end repeat


            tell document 1 to save

            tell document 1 to close



        end tell

    end try

end adding folder items to