Eject all locally mounted disks via AppleScript

May 30, '08 07:30:02AM

Contributed by: loren_ryter

If you're like me, you tend to install several updates and/or software packages at once. When through, I like to eject all my mounted disk images with a simple AppleScript:

tell application "Finder"to eject (every disk whose ejectable is true and local volume is true and physical size < 1.0E+9)

Technically, this doesn't look for mounted DMGs but rather for ejectable, local (ie, non-network) disks with a size less than about 1GB. For most purposes, this will do the job. Copy and paste the above into Script Editor and save the resulting script in ~/Library/Scripts, then access it from the Scripts menu. Alternatively, add it to your tool bar, side bar, or assign it a hot key (with a third party hot key program), etc.

[robg adds: As this script only checks for size and ejectable status, it may have unintended results depending on your system configuration. When I ran it, it ejected one (but not both) of my mounted CDs, but didn't eject the Time Machine disk. I would expect mounted FireWire drives may also be ejected.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080529142859915