Automatically Run a Sync When a Specific Application Closes Create an AppleScript that, with the use of the application Do Something When, will trigger a sync to run when a specific application closes

TNCS-0016 – Automatically Run a Sync When a Specific Application Closes

Created: March 23, 2014

ChronoSync does not directly support scheduling a sync to run when an application closes. Use this document to create an AppleScript that, with the use of the application Do Something When, will trigger a sync to run when a specific application closes.

RESOLUTION

Use the following steps to monitor when an application closes with ‘Do Something When’ and create an AppleScript that runs a sync. This procedure makes use of the AppleScript Editor which be found in the Applications->Utilities folder as well as the utility ‘Do Something When’ available from their website.

Open the AppleScript Editor

Open the Utilities folder, found in the Applications folder of your Mac, then open the AppleScript Editor.

Create the AppleScript

Copy the following script and paste it into the AppleScript Editor:

tell application “Finder” to open alias “Mavericks:Users:Hartigan:Desktop:Test.sync”
tell application “ChronoSync”
activate
set myDocument to document “Test”
tell myDocument
Synchronize
delay 1
repeat while syncStatus is not 0
delay 1
end repeat
save
close
end tell
quit
end tell

Modify the path name in quotes after the term ‘alias’ to name the saved sync document, and modify “Test” after the term ‘document’ to the exact name of the saved sync document as displayed in the sync document’s titlebar. (This would be the sync document name without any filename extension.)

Compile and Test

Click the ‘Compile’ button in the AppleScript Editor toolbar. Check for any errors. Now, test the script. Remember, if everything works, the sync document should open and begin syncing! Now click the ‘Run’ toolbar button. Does the sync get launched? Correct any errors before continuing.

Save the AppleScript

Save the AppleScript by going to the menubar and choosing File -> Save. Make sure to choose the ‘Application’ File Format. Choose a directory to store the AppleScript, then choose ‘Save’.

Download and Install 'Do Something When'

Download Do Something When (DSW) from the link below:

https://do-something-when.en.softonic.com/mac

Double-click DSW.pkg to run through the installer.

Launch DSW From System Preferences of your Mac

Locate the DSW icon located under Other in System Preferences of your Mac.

Enable 'Automatically Start on Login' and 'Start' the Service

Configure the AppleScript in Do Something When

Create a rule that launches an AppleScript (that launches the sync) after an application closes. This tech note will use Spotify as an example application that will trigger the sync to run when quit. Give the rule a name, something to remind you of its purpose. Change the “Mounts” popup to “Quits”. Set the “When” popup to “Select Application…”:

Choose the Application to Trigger the Sync

Select the AppleScript to Run the Sync

Click the blank popup next to the What / Open popup, select “Select Application or Document”, then choose the AppleScript:

Setup a Delay, then Save the Do Something When Rule

Enter a safe Delay value, something long enough for the application to quit before the script launches the sync. Then click Save:

CONCLUSION

If all has gone well, the sync document should run approximately 10 seconds after Spotify, or the application you’ve chosen, is closed.

REVISION HISTORY

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

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