Daily Archives:February 19th, 2008

Eject All

Every day I unplug my MacBook Pro from a set of disks and other peripherals at home, take it into the office and plug it into a new set there. In the evening, I do the same going home.

One thing that makes this much less painful than it might otherwise be is a keystroke shortcut I set up a long time ago, based on this hint. Now I just type Cmd-F1, and all my external disks are unmounted. This is exceedingly handy!

To do this, create an AppleScript containing the following:

tell application "Finder"
        activate
	set bootDisk to name of startup disk
	set otherDisks to every disk whose (name is not bootDisk)
	repeat with myDisk in otherDisks
		try
			eject myDisk
		end try
	end repeat
end tell

Save it somewhere and configure your favourite utility to run it. I use QuickSilver and set it up as a trigger.

It won’t work, of course, if you have an application running using one of the disks, so it’s good to check the Finder window before actually unplugging them.

© Copyright Quentin Stafford-Fraser