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


Click here to return to the 'An AppleScript to unmount multiple volumes at once' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to unmount multiple volumes at once
Authored by: hypert on Oct 26, '04 09:43:50PM
I haven't examined this entire script, nor looked at the exact capabilities of the "disktool" terminal command, but the script seems a little over-kill. I've been using this simple script to eject scripts, and it uses all AppleScript (no system/terminal calls).

tell application "Finder"
	set bootDisk to name of startup disk
	set otherDisks to every disk whose (name is not bootDisk) and (name is not "Media")
	repeat with myDisk in otherDisks
		try
			eject myDisk
		end try
	end repeat
end tell
This ejects everything except your boot disk, and a disk called "Media", in my example. Feel free to build your own exception list by just modifying and adding on to the otherDisks definition.

[ Reply to This | # ]
the script seems a little over-kill
Authored by: platon on Oct 27, '04 04:29:02PM

What's about ejecting CD- or DVD-Rom's. What's about a partition which resides on the same Harddisk like your Startup-Partition. What's about to not eject every disk but to select them.



[ Reply to This | # ]
Unmount selected disks
Authored by: sinjin on Oct 28, '04 02:37:42PM
Regarding the applescript by hypert, the following change will eject only selected disks. In trying it out I noticed that it will only eject ejectable items (iPods, dmg, shares, removable disks), so no need to exclude the startup volume or anything else for that matter. i.e. if you mistakenly select files or folders, the Finder seems to ignore them and continue ejecting everything else. Not sure how it deals with partitions, I don't have any.


tell application "Finder"
	set selectedDisks to selection
	repeat with myDisk in selectedDisks
		try
			eject myDisk
		end try
	end repeat
end tell

I have no idea if this covers the functionality of platon's original script (I suspect it may not), but present it as a solution that works for me.

[ Reply to This | # ]

Thanks, with iKey your applescript makes it easy to unmount external Hard Drives
Authored by: peterrosen on Apr 12, '06 04:03:29PM
Thanks for your script, it works like a charm. When I call it, saved as an application using iKey, I can unmount my external HD's with a keystroke. since I am always connecting and disconnecting my laptop, this comes in real handy. If I feature this tool over at Creativity Cafe, I'll let you know. Aloha, Peter

[ Reply to This | # ]