15

I have an external disk with two partitions on it that I keep plugged into my MacBook Pro when I'm at my desk. (One is for Time Machine, the other just for extra storage.) Sometimes I need to grab my laptop quickly and take it somewhere, but I have to change to a space where I can see the partitions on the desktop, lasso them, two-finger click, and select Eject. Is there a faster way under Mavericks, or do I have to set up an AppleScript like this one with a keyboard shortcut?

Note: I'm not looking to eject these only when I put my Mac to sleep (as explored here). Sometimes I'm on a screen-sharing telecon and I have to take my Mac away from my desk for a minute, if you know what I mean :-).

  • I use Alfred.app to do this task. It makes it as easy as pressing <kbd>cmd</kbd>+<kbd>space</kbd> and typing eject. Highly recommended – wrossmck Aug 28 '14 at 15:07
  • Lots of good answers below. I'm having a tough time choosing one as the best. – Jim L. Aug 29 '14 at 13:58
  • This place ain't big enough for two of us,@JimL. Guess I'll have to go. (sorry I know my comment is irrelevant but I saw his name on another post and thought, "I didn't write that!" Really did a double take. – JimLohse Jan 16 at 23:57

11 Answers 11

7

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!).

  • This still works under Mavericks. – Jim L. Aug 29 '14 at 13:57
  • This turns out to be the most satisfying answer for me. One quick key chord and it's done. No extra software needed. Thanks! – Jim L. Nov 9 '14 at 4:50
  • 2
    Seems not to work anymore on El Capitan. Can anyone confirm? – Matteo Mar 2 '16 at 13:46
  • @Matteo Still works for me! – Jim L. Mar 22 '16 at 21:50
10

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)

Enter Code in your Script Editor

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.

Select 'Application' as your file format

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've wrapped this in a Ruby script in my answer here... sort of the same thing over again... – Dan Rosenstark Nov 12 '15 at 23:25
  • I've put this Applescript to execute in a service and then created a keyboard shortcut in the System Preferences and it works perfectly. – juil Mar 12 '17 at 1:48
  • This is my favorite answer because it uses native MacOS stuff. It however doesn't really address the need to quickly physically disconnect external drives. "I have to take my Mac away from my desk for a minute". So, if script ejects only ejectable drives and some were not ejectable at that time - it'd be great if we were warned before removing the cable and heading to another room! – tishma Jun 21 at 18:01
7

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.).

alfred eject command

When you trigger the shortut, you can select a specific volume to unmount. Or you can type ejectall (this shortcut name is customizable).

  • 1
    Note: you'll need to enable these built-in Alfred commands by going to Alfred Preferences -> System -> Eject and Preferences -> System -> "Eject All" alfredapp.com/help/features/system – cody.codes Oct 17 '18 at 21:07
3

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.

1

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

1

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.

1

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.

0

This can be done elegantly with an automator application and using the Display Notification feature for output. Simply save the following as an application and launch it however you prefer.

enter image description here

0

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.

enter image description here

0

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
-2

On macOS Mojave, you can just simply select both of the drives you want eject and click "CMD+E". This will eject both of your disks without any prompts.

  • 1
    That’s exactly what the original question was looking to avoid! – Jim L. Aug 21 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .