Eject All of your Removable Mac OS X Disks Quickly!

Are you always using hard disks and USB keys in your Mac? Getting annoyed with having to go to the Finder, scrolling down in the sidebar, and then ejecting these disks before you can unplug all of these devices to move your computer? Or, maybe you just pull out the USB and let Mac OS X complain at you about how the disk was removed without you ejecting it first?

Try using this AppleScript along with a launcher application like QuickSilver to save time and eject all of your disks with one command! A launcher application is basically a quick way to start up applications – you press a keystroke like “Ctrl-Space” and then begin typing, and QuickSilver will find applications that match what you’ve typed. Ejecting disks is quite literally at your fingertips.

  1. Open up the AppleScript Editor (it’s in /Applications/Utilities)
  2. Copy and paste the following code:
    try
      tell application "Finder"
        eject the disks
        display dialog "Successfully ejected disks." buttons {"Close"} default button "Close"
      end tell
    on error
      display dialog "Unable to eject all disks." buttons {"Close"} default button "Close"
    end try

    AppleScript Editor with the Eject All script

    AppleScript Editor with the Eject All script.
  3. Save it into a place you’ll find it later. I used ~/Library/Scripts and called the script “EjectAll.scpt”.
  4. Compile it!

Now, if you double-click on that script, it’ll automatically eject all of your media and give you a dialog box to let you know when it’s finished.

quickSilverCatalogScripts

QuickSilver Catalog Preferences Window

In QuickSilver, I added the ~/Library/Scripts directory to my catalog by opening the QuickSilver Preferences, clicking on Catalog, then going to Scripts in the sidebar. I then ensured that “Scripts (User)” was checked.

Then, you can relaunch QuickSilver, press its hotkey (Ctrl-Space by default), and type “EjectAll” and press enter to run the script. It’ll automatically eject all of your media and then you can pull out all of your plugged-in devices without worry!

Advertisements

One thought on “Eject All of your Removable Mac OS X Disks Quickly!

  1. Rory Barton

    I came across this because I was looking for this solution. I made a couple changes. I used Automator’s Run AppleScript command, and added a timeout on the success dialogue. I then saved it as a service making it available in the apple menu. Cheers.

    Reply

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s