Introduction to Scripting with ChronoSync Create AppleScripts and use them in ChronoSync to automate tasks before and after your syncs

TNCS-0009 – Introduction to Scripting with ChronoSync

Created: March 15, 2014 | Updated: April 11, 2014

What is AppleScript? It’s a scripting language created by Apple that can be used to automate actions on your Mac. You can create AppleScripts and use them in ChronoSync to automate tasks before and after your sync as pre-synchronization and post-synchronization scripts in your saved sync or container document. You can even automate ChronoSync sync jobs by running them directly via AppleScript if you wish.

DISCUSSION: APPLESCRIPTING IN CHRONOSYNC

There are many ways to use AppleScripts with ChronoSync. The most common method is through the use of pre-synchronization or post-synchronization scripts that automate tasks before or after a sync job is run. You can configure pre-sync and post-sync scripts in the Scripts section of the Options Panel of your saved sync document.

Keep in mind that this discussion focuses upon AppleScripts. Beyond that, ChronoSync can also execute shell script files and applications as a pre- or post- sync ‘script’. In the case of applications, ChronoSync will simply launch the application but will not wait for it to terminate. In the case of AppleScripts and shell scripts, ChronoSync will wait for completion prior to continuing.

A Pre-Synchronization script can be used to accomplish many things before a sync, but perhaps the most common use is to mount an external drive (connected via USB, FireWire, etc.) on your Mac running ChronoSync. You can create a script that scans the mounted volumes for a specific volume name, and if that volume is not available, the script will attempt to mount it.

A Post-Synchronization script can be used in a similar fashion, but it runs after the sync has finished rather than before a sync has started. This is useful for ejecting volumes that were mounted prior to the sync, or shutting down the machine running ChronoSync when the sync has finished.

Finally, you can run schedules and sync documents directly via AppleScript. This is useful for when you’ve already got an existing AppleScript that accomplishes a series of tasks (such as quitting applications and exporting databases to be backed up by ChronoSync), and you want run your sync only when these tasks have been accomplished. You can add a few additional lines to the AppleScript that tell ChronoSync to run the sync for you. The only caveat is that the sync document and schedule must exist prior to running the script. You cannot create a sync document or schedule via AppleScript.

AppleScripting in ChronoSync provides a corridor to expanding or enhancing ChronoSync when a custom feature or operation isn’t readily available.

APPLICATION

Below is a list of example AppleScripts available to use and modify for your specific sync needs:

Automatically Mount a Volume Before Running a Sync

Use this AppleScript example to scan for a specific volume and mount it, if unavailable, before your sync document starts. This is useful if you keep your backup volume ejected except when actively backing up.

Automatically Un-Mount a Volume After Running a Sync

Use this AppleScript example to scan for a specific volume and eject it, if available, after your sync document has finished. Similar to above, this is useful if you keep your backup volume ejected except when actively backing up.

Automatically Shut Down Your Mac After Running a Sync

Use this AppleScript example to shut down the Mac ChronoSync is installed on after your sync document has finished. This is useful because you can launch your sync at the end of the day and walk away knowing the Mac will be shut down when the sync completes.

Automatically Restart Your Mac After Running a Sync

Use this AppleScript example to restart your Mac after your sync document has finished.

Automatically Log Out of Your Mac After Running a Sync

Use this AppleScript example to log-out of your user account after your sync document has finished. This is useful because you can launch your sync at the end of the day and walk away knowing the Mac will be logged out when the sync completes.

Automatically Run Your Sync via AppleScript

Use this AppleScript example to create an AppleScript command that, upon launching, tells ChronoSync to open a sync document, synchronize, then close ChronoSync. This is useful if you want a command on your desktop to immediately run a sync, or if you want to incorporate running a sync document into a larger, automated work-flow.

Automatically Run a Sync When a Specific Application Closes

Use this example to create an AppleScript that you can then launch with the application Do Something When to trigger a sync to run when a specific application closes. This is useful when you always want to backup some files when you finish working with them in a specific application.

Automatically Sleep Your Mac After Running a Sync

Use this example to create an AppleScript so you can automatically put your Mac to sleep after a sync is run. This is useful when you want your Mac to stay asleep after waking it up just for the sync.

Automatically Run Your Sync Silently via AppleScript

Use this example to create an AppleScript that will run a sync document silently as if it were being run from ChronoSync’s background scheduler.

REVISION HISTORY

Apr-11-2014 – Added tech notes TNCS-0018 and TNCS-0019.

Mar-15-2014 – Created from Internal Support Notes.

Shopping cart0
There are no products in the cart!
Continue shopping
0