Applescript with Growl notifications

Growl is a notification system for Mac OS X: it allows applications that support Growl to send you notifications. Thankfully the peeps at growl have afforded us integration with applescripts. I use growl notifications to provide a bit more feedback when backing up my mac to a USB drive. Good for those long running scripts …

You can find out more about the growl notifications here.

growlnotifcation.png


Detailed below is an example of my backup script which uses rsync to keep multiple folders in sync with a backup USB drive.


set fromFolder to "~/"
set toFolder to "/Volumes/Storage"

tell application "GrowlHelperApp"
set the allNotificationsList to ¬
{"SyncWiz", "SyncWiz"}
set the enabledNotificationsList to ¬
{"SyncWiz"}
register as application ¬
"SyncWiz" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Script Editor"
end tell

display dialog "BACKUP MacBookPro
-----------------
From: " & fromFolder & "
To: " & toFolder & "" buttons {"Yes", "No"}
set dialog_answer to button returned of result
if dialog_answer = "Yes" then
do shell script "rsync -rt --delete " & fromFolder & "/Documents "
& toFolder & " " with password
tell application "GrowlHelperApp"
notify with name ¬
"SyncWiz" title ¬
"SyncWiz" description ¬
"SyncWiz: Finished backing up documents ..." application name "SyncWiz"
end tell

do shell script "rsync -rt " & fromFolder & "/Desktop "
& toFolder & " " with password
tell application "GrowlHelperApp"
notify with name ¬
"SyncWiz" title ¬
"SyncWiz" description ¬
"SyncWiz: Finished backing up desktop ..." application name "SyncWiz"
end tell

do shell script "rsync -rt " & fromFolder & "/Games "
& toFolder & " " with password
tell application "GrowlHelperApp"
notify with name ¬
"SyncWiz" title ¬
"SyncWiz" description ¬
"SyncWiz: Finished backing up games ..." application name "SyncWiz"
end tell

do shell script "rsync -rt " & fromFolder & "/Parallels "
& toFolder & " " with password
tell application "GrowlHelperApp"
notify with name ¬
"SyncWiz" title ¬
"SyncWiz" description ¬
"SyncWiz: Finished backing up parallels ..." application name "SyncWiz"
end tell

do shell script "rsync -rt " & fromFolder & "/Pictures "
& toFolder & " " with password
tell application "GrowlHelperApp"
notify with name ¬
"SyncWiz" title ¬
"SyncWiz" description ¬
"SyncWiz: Finished backing up pictures ..." application name "SyncWiz"
end tell

do shell script "rsync -rt " & fromFolder & "/Public "
& toFolder & " " with password
tell application "GrowlHelperApp"
notify with name ¬
"SyncWiz" title ¬
"SyncWiz" description ¬
"SyncWiz: Finished backing up public ..." application name "SyncWiz"
end tell

do shell script "rsync -rt " & fromFolder & "/Sites "
& toFolder & " " with password
tell application "GrowlHelperApp"
notify with name ¬
"SyncWiz" title ¬
"SyncWiz" description ¬
"SyncWiz: Finished backing up sites ..." application name "SyncWiz"
end tell

do shell script "rsync -rt --delete ~/Library/Mail/ "
& toFolder & "/Mail/Library/Mail" with password
do shell script "rsync -rt --delete ~/Library/Mail\\ Downloads/ "
& toFolder & "/Mail/Library/Mail\\ Downloads" with password
do shell script "rsync -rt --delete ~/Library/Preferences/ "
& toFolder & "/Mail/Library/Preferences/ --include=com.appl.mail.plist" with password
do shell script "rsync -rt --delete ~/Library/Application\\ Support/AddressBook/ "
& toFolder & "/Mail/Library/Application\\ Support/AddressBook/" with password

display dialog "Your backup is done!"
end if

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">