I very often have a lot of different Volumes (hard disks, disk images, ROMs, Servers, etc.) mounted. To eject a single partition on a hard disk, I need help from Disk Utility. And in the Finder's sidebar, only removable volumes are ejectable. The same is true in open/save dialogs. I can eject any volume in the Terminal, but I have to know the correct command (umount, hdiutil, disktool, etc.). This procedure is very painful when I want to unmount many different volumes of different types.
So I created this AppleScript to eject all the selected volumes within a second (except my Startup disk, of course!). For each "disk unmount command," the script opens a new Terminal window to eject the volume. This may be annoying, but it's fast. The more elegant way is not to tell Terminal to execute the command, but to do it directly with the Script:
do shell script "disktool -e disk2"
This works, but it takes more than 15 seconds to eject one volume -- and there is no error message if something goes wrong. Servers are unmounted this way, that works very smooth. I don't know why the behavior of the commands differs if executed by Terminal or by System Events. And finally: An image ejected by this script can be remounted easily -- without the help of Disk Utility.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20041024142036862