Skip to content

Instantly share code, notes, and snippets.

@LarsEliasNielsen
LarsEliasNielsen / eject_timemachine.as
Created January 23, 2014 15:20
AppleScript to stop current backup, eject Timemachine disk. My Timemachine disk has another partition, so this is ejected also. Notofications is displayed when disks are ready to be disconnected.
-- Stops current backup do shell script "/Applications/'Time Machine.app'/Contents/MacOS/'Time Machine' 3" -- Set disk names set wd to "WD" set timemachine to "TIMEMACHINE" -- Eject WD tell application "Finder" if disk wd exists then eject disk wd display notification "WD disk has successfully been ejected" with title "WD ejected" else display notification "WD disk was not mounted" with title "WD not mounted" end if end tell -- Eject TIMEMACHINE tell application "Finder" if disk timemachine exists then eject disk timemachine display notification "TIMEMACHINE disk has successfully been ejected" with title "TIMEMACHINE ejected" else display notification "TIMEMACHINE disk was not mounted" with title "TIMEMACHINE not mounted" end if end tell