I use that shortcut system-wide for something else. Unfortunately although you can set menu item shortcuts from the settings, you can set it for a specific menu item. That means I can set it for Eject, but if I have a drive called Test it'll become Eject "Test" which I obviously won't have a shortcut for.

I would also prefer not having to drag the drive all the way to the drive each time.

  • 1
    Just to clarify, are you wanting to change the behaviour of the Media Eject key on your keyboard, or the behaviour of the Command + E keyboard shortcut? If you're just looking for another way to eject drives, you also have the options of (a) right-clicking on the drive and selecting the Eject option, or (b) selecting the drive and pressing Command + E .
    – Monomeeth
    Sep 27, 2016 at 22:11
  • @Monomeeth I'm trying to change the command E shortcut to something else, such as Alt E perhaps. I could right click and eject it, though that seems a bit unnecessary.
    – Oion Akif
    Sep 27, 2016 at 22:13
  • 1
    And what about using the Media Eject key, usually at the top right of the keyboard, for ejecting instead? Or do you ave a keyboard without this key?
    – Monomeeth
    Sep 27, 2016 at 22:15
  • @Monomeeth that would have been amazing, but I just tried it out and it doesn't work. It simply works for physical media (CDs) it would seem.
    – Oion Akif
    Sep 27, 2016 at 22:20
  • 1
    In that case I think I have a way around this for you. It's a little convoluted because it uses a combination of AppleScript and Automator, but shouldn't take too long to set up and create a keyboard shortcut for. Not sure how well it'll work in practice compared to just right-clicking with the mouse and selecting Eject, but I'm happy to put an answer together for you explaining what I'm thinking. Probably won't get the chance to post it for at least 9 or 10hrs though. Will be interested to see how well it works. :)
    – Monomeeth
    Sep 28, 2016 at 12:12

1 Answer 1


The only way I can think of to achieve this without any 3rd party software is to do the following steps:

  • Use Automator to create a service that runs an Apple Script
  • Use System Preferences to assign a keyboard shortcut to the service

Below are the steps involved for each. Don't worry, the whole thing should only take 5-10 mins.

1. Create a service using Automator

  1. Launch Automator (usually found within your Applications folder)
  2. Go to File > New.
  3. Select Service and click Choose.
  4. In the top right hand of the window that appears, ensure that "No input" is selected from the Service receives drop-down list.
  5. Ensure the In drop-down list is showing "Any application".
  6. In the second column containing the long list, find "Run AppleScript" and double-click on it.
  7. This will add the Run AppleScript window on the right.
  8. Now, replace the ( Your script goes here ) with the following code:

set exceptionsList to {"HD1", "HD2", "HD3", "HD4"}
tell application "Finder"
    set diskList to the disks
    repeat with mountedDisk in diskList
        if name of mountedDisk is not in exceptionsList then
            eject mountedDisk
        end if
    end repeat
end tell

  1. In the first line of code, add your exceptions by changing the references to HD1, HD2, etc to any names of drives you do not want to eject. For example, HD1 should be replaced by your Macintosh HD (or whatever it's called). You may also want to add any Time Machine drives to the list, etc. You can add more by adding a comma and placing the name within quotes. Likewise, you can remove any you don't need.
  2. Save the service using a meaningful name (e.g. EjectAll).

Now to the next step.

2. Creating your shortcut

  1. Go to System Preferences > Keyboard > Shortcuts.
  2. Select Services from the sidebar.
  3. Find your service (it'll be in the list on the right-hand side).
  4. Add a shortcut by double clicking on the service name.
  5. Now go to System Preferences > Security & Privacy > Privacy.
  6. Select Accessibility in the sidebar.
  7. Click on the + sign (you may need to unlock the padlock if it's locked).
  8. Add Automator.
  9. Add Finder (to find this you will need to navigate to /System/Library/CoreServices/Finder.app).
  10. Exit your System Preferences.

Now you should be able to do two things:

1. Eject your drives from any application by going to the Services list within any Application menu (e.g. Finder > Services, Safari > Services, Mail > Services, etc) and select the service you just created. This will eject all drives not within your exception list.

2. Use the keyboard shortcut to run the service.

NOTE: I am aware that for some users keyboard shortcuts do not seem to work even though they've been assigned to a service. This is a whole other topic, but if this happens in your case, at least you should now be able to eject all drives from within any application you're using.

Hope this helps you and others.

  • This is honestly the most amazing answer I have ever received. Thank you so much! I will try it out as soon as I can and let you know about it :)
    – Oion Akif
    Sep 29, 2016 at 5:29
  • I finally tried it, and it works great! Thanks a lot :)
    – Oion Akif
    Dec 27, 2016 at 23:19
  • No worries, I'm glad it suited your needs!
    – Monomeeth
    Dec 27, 2016 at 23:44

You must log in to answer this question.

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