Hey guys,
I’ve received a lot of help from this community. Here’s a simple script I wrote for ejecting disks from my mac. I run it as an applet and keep it on my dock for quick access. Here’s the script itself and a link to the script as an applet (complete with a nice icon!)
Hope you like it.
Tim
PS the link may be dead in a month or so, depending on if I change something and archive it again, changing the dropbox link.
https://www.dropbox.com/s/v7pgbj3f0fv6d5j/Eject%20Disk(s).zip
on ejectalldisks()
repeat
try
tell application "Finder"
set bootDisk to name of startup disk
set otherDisks to every disk whose (name is not bootDisk) -- and (name is not "Media")
if (count of otherDisks) is 0 then
return 1
end if
repeat with myDisk in otherDisks
try
eject myDisk
on error
tell me to activate
tell me to display dialog "There was a problem ejecting " & (myDisk as text) with icon stop
return "Failed"
end try
end repeat
exit repeat
end tell
end try
end repeat
return 1
end ejectalldisks
on run
tell application "Finder"
set bootDisk to name of startup disk
set otherDisks to every disk whose (name is not bootDisk) and (name is not "MobileBackups") and (name is not "Boot OS X") and (name is not "home") and (name is not "net")
end tell
if (count of otherDisks) = 0 then
return 0
end if
set diskNames to {"All"}
tell application "Finder"
repeat with myDisk in otherDisks
set end of diskNames to name of myDisk
end repeat
set ejectDiskNames to choose from list diskNames with prompt "Choose disk(s) to eject" default items {"All"} with multiple selections allowed
if ejectDiskNames = false then
return 2
else if ejectDiskNames = {"All"} then
my ejectalldisks()
else
set ejectDisks to {}
repeat with ejectDisk in otherDisks
if ejectDiskNames contains (name of ejectDisk) then
set end of ejectDisks to ejectDisk
end if
end repeat
repeat with myDisk in ejectDisks
try
eject myDisk
on error
tell me to activate
tell me to display dialog "There was a problem ejecting " & (myDisk as text) with icon stop
return "Failed"
end try
end repeat
end if
tell me to activate
tell me to display dialog "Selected disk(s) ejected" giving up after 1 with icon note
end tell
return 0
end run