Skip to content

Instantly share code, notes, and snippets.

@LukeChannings
Created September 7, 2011 15:55
Show Gist options
  • Save LukeChannings/1200956 to your computer and use it in GitHub Desktop.
Save LukeChannings/1200956 to your computer and use it in GitHub Desktop.
Synchronise USB Stick when inserted OS X.
#!/bin/bash
# Mount the volume.
/sbin/mount_msdos.real "$@"
# MODIFY TO FIT YOUR NEEDS.
LABEL="HUBBLE" # USB Stick Label.
USBFOLDER="College Work" # Name of the folder on the USB Stick. (Can be a relative path.)
DESTINATION="/Volumes/Media/Dropbox/College Work" # Folder to which the USB Stick will be synchronised.
# DO NOT EDIT BELOW THIS LINE.
sleep 3 # Wait a bit for the USB Stick to be mounted.
# Check that the USB Stick is there..
if [ -d "/Volumes/$LABEL" ]; then
say "Synchronizing your USB Stick."
# Rsync
rsync -auv "/Volumes/$LABEL/$USBFOLDER/" "$DESTINATION/"
rsync -auv "$DESTINATION/" "/Volumes/$LABEL/$USBFOLDER/"
say "Synchronization complete."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment