Automatically Un-Mount a Volume After Running a Sync Create a post-sync AppleScript that scans for a specific volume and un-mounts it if it is available

TNCS-0011 – Automatically Un-Mount a Volume After Running a Sync

Created: March 21, 2014

ChronoSync does not directly support automatic un-mounting of external drives connected via USB, FireWire, or Thunderbolt. Use this document to create a post-synchronization AppleScript that scans for a specific volume and un-mounts it if it is available.

RESOLUTION

Use the following steps to create the post-sync AppleScript to eject the desired volume. Be sure to make the required changes so that the script searches for your desired volume name. This procedure makes use of the AppleScript Editor which be found in the Applications->Utilities folder.

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. Change the word “Storage” to the name of the volume you’d like to mount (keep the quotes). This name can be found as the label underneath a mounted volume icon or at the top of the Get Info window for the desired volume.

set myVolumeLabel to “Storage”
tell application “Finder”
set diskDev to do shell script “diskutil list | grep \”” & myVolumeLabel & “\” | grep -o ‘disk[1-9]*’ “
if (disk myVolumeLabel existsthen
do shell script “diskutil unmountDisk ” & diskDev
end if
end tell

Compile and Test

Click the ‘Compile’ button in the AppleScript Editor toolbar. Check for any errors. Now, test the script. First, make sure the volume being addressed in the script is mounted. Now click the ‘Run’ toolbar button. Does the volume get ejected? 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 ‘Script’ File Format if it is not chosen already. Choose a directory to store the AppleScript, then choose ‘Save’. It may be helpful to keep any scripts in the same folder where the sync document is stored.

Set the Script in your Sync Task

Open the saved sync document and switch to the Options Panel. Expand the ‘Scripts’ section.

Enable ‘Post-Synchronization script’, then click the ‘Choose’ button and select the AppleScript just created.

Choose whether or not to abort the sync run if the AppleScript encounters an error by enabling or disabling ‘Abort on Script Errors’.

Test the script by clicking ‘Run’.

CONCLUSION

If all has gone well, the AppleScript should have launched before running your sync, and the volume that was previously mounted should now be un-mounted and no longer accessible via Finder or ChronoSync.

REVISION HISTORY

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

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