Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Eject all locally mounted disks via AppleScript System
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.]
    •    
  • Currently 2.33 / 5
  You rated: 5 / 5 (9 votes cast)
 
[11,563 views]  

Eject all locally mounted disks via AppleScript | 5 comments | Create New Account
Click here to return to the 'Eject all locally mounted disks via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Eject all locally mounted disks via AppleScript
Authored by: DougAdams on May 30, '08 08:24:56AM

You might want to check the disk's free space property, which would be 0 if it's a CD or DVD.


---
Doug's AppleScripts for iTunes
dougscripts.com



[ Reply to This | # ]
Eject all locally mounted disks via AppleScript
Authored by: packhater on May 30, '08 10:02:59AM

Did not work for any of my afp, smb or firewire mounted drives. Should it? Or this only fro cds?



[ Reply to This | # ]
Eject all locally mounted disks via AppleScript
Authored by: CajunLuke on May 30, '08 10:08:23AM
Well, it's not going to work for your afp or smb drives, as they are network disks (i.e. not "local"), and I don't know of any FireWire disks that are less than one gigabyte, so it wouldn't eject those, either. Moreover, the script is intended to not eject those kinds of disks.

[ Reply to This | # ]
Eject all locally mounted disks via AppleScript
Authored by: vocaro on May 30, '08 10:39:21AM
Eject all locally mounted disks via AppleScript
Authored by: kscotto on May 30, '08 10:41:29AM

This is what I've been looking for. I changed the value of the disk so that it would eject my USB backup drive (since every time I take my laptop I had to access finder and press Opt and click on the unmount arrow to eject). I assigned the script a hot key via Butler, and now I can eject the disk quickly before I leave with a hotkey combo. Thanks for the tip!



[ Reply to This | # ]