How to Eject All External Partitions Quickly?
The only caveat to "quickly ejecting" disks with any reliability is that they will not eject if there are files in use which reside on them. That said, you can force eject disks, but that would not be ideal if files are, in fact, in use.
Easiest way to instantly eject all disks is by invoking an Applescript (could also create a shell script, but Applescript is more easily turned into a one-click application solution).
So go to your Applescript Editor, paste in the following:
tell application "Finder" to eject (every disk whose ejectable is true and local volume is true and free space is not equal to 0)
and save the script as an application wherever you choose (do NOT use the /tmp
folder as illustrated). Add the resulting application to your Dock, and you have a one-click Quick Eject.
Note: the and free space is not equal to 0
portion is so that the script doesn't eject the contents of your CD/DVD drive. Remove that if you would like any inserted disks ejected as well.
I'd recommend Alfred. It's a quick launching app that includes the feature of ejecting volumes. You can select what kind of targets qualify for the command (network drive, local, etc.).
When you trigger the shortut, you can select a specific volume to unmount. Or you can type ejectall (this shortcut name is customizable).
On OS-X Mountain-Lion, I can option-click one of the "Eject" icons (hold down option, then click the eject icon), and all external partitions will eject.
(Update) This has been verified to also work on OS X Mavericks and even on macOS Sierra, as I suspected it would. It can probably be assumed to work on at least all versions in between (try it out!).
I use launchbar to automate this task. It has a command shortcut to Eject All Ejectable Volumes. It's incredibly fast and if you turn off most of the indexing rules, the memory footprint and CPU usage can be tiny.
It's much more powerful than this one trick, but it does do that trick very well and you'd probably be fine using the free version for that purpose since you'd only be using that one shortcut.
The AppleScripts above eject all ejectable disks, sadly this also includes cloud disks such as Box.com/Google Drive etc.
In order to eject only non-cloud disks I tweaked the script slightly to:
tell application "Finder" to eject (every disk whose ejectable is true and local volume is true and format is not unknown format)
Hope this helps anyone who comes here looking for this.
You can use the menu bar app Ejector http://www.macupdate.com/app/mac/12216/ejector to eject all ejectable volumes. The only regrettable part for me is that I can't eject them without logging in.
Personally, I'm using Alfred as suggested in another answer. But here's the Applescript answer, wrapped up in a Ruby script.
#!/usr/bin/env ruby
#eject-all shell script
# Dan Rosenstark 2015-11-12 15:28
# http://porkrind.org/missives/calling-applescript-from-ruby/
def osascript(script)
system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
end
if __FILE__ == $0
appleScript = "tell application \"Finder\" to eject (every disk whose ejectable is true and local volume is true and free space is not equal to 0)";
osascript appleScript
puts "I probably ejected all the disks."
end
you'll have to put it in your path and make it executable.
if you happen to have the same setup everytime you want to eject several external disks at once, you could use AppleScript / Automater and make your own keyboard shortcut. There is a detailled description how to do this over here: https://superuser.com/questions/405330/global-keyboard-shortcut-to-eject-external-hard-drive-on-mac-osx-lion
I use a combination of AppleScript and an application called Spark. Spark is on Github for Homebrew Casks.
brew install Caskroom/cask/spark
Then I just use an AppleScript to eject the drives and bind it to the shortcut ⌘ E.
For disks with partitions, I've found the following Applescript works best.
tell application "System Events"
key down option
tell application "Finder"
with timeout of 15 seconds -- make sure we stop
eject (every disk whose ejectable is true)
end timeout
end tell
key up option
end tell