Last active
August 29, 2015 13:57
-
-
Save jswright61/9398985 to your computer and use it in GitHub Desktop.
This applescript script will automatically unmount any mounted volume or disk that is not listed as a protected disk.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set counter to 0 | |
set ejectedDisks to "" | |
set pad to "" | |
-- this should be a list of the disks you do not want automatically unmounted | |
set protectedDisks to {"Macintosh HD", "Another Disk you do not want unmounted"} | |
tell application "Finder" | |
set mountedDisks to list disks | |
end tell | |
repeat with currentDisk in mountedDisks | |
if currentDisk is not in protectedDisks then | |
set counter to counter + 1 | |
set ejectedDisks to ejectedDisks & pad & currentDisk | |
set pad to ", " | |
tell application "Finder" | |
-- test this first | |
-- when satisfied, remove the -- in front of eject | |
-- add -- in front of display dialog | |
display dialog currentDisk | |
--eject currentDisk | |
end tell | |
end if | |
end repeat | |
-- if you don't want a system notification, add -- in front of the lines below | |
if counter = 1 then | |
set plural to "" | |
else | |
set plural to "s" | |
end if | |
display notification time string of (current date) & " | |
" & ejectedDisks ¬ | |
with title ((counter) as string) & " Disk" & plural & " Ejected" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment