Volumes Returned in a List to UnMount

Hi Guys,

is there anyway to get a list of plugged in USB drive volumes to be returned in applescript?

I am wanting to get a list to return, then i am going to add code to eject / unmount the selected drive.

Thanks

Hi,

try this, maybe it’s sufficient


tell application "System Events"
	set ejectableLocalDisks to disks whose local volume is true and ejectable is true
end tell

Hi Stefan,

Having an issue with this, im sure it’s a simple fix but it is alluding me:


tell application "System Events"
	set ejectableLocalDisks to disks whose local volume is true and ejectable is true
	do shell script "diskutil unmount" & ejectableLocalDisks
end tell

The request to fin the drives is perfect, i then call the variable later in my do shell script unmount.

However, this fails as for some reason i have data that cannot be converted:

** I suspect its the ID Data -104,2 thats causing this?

first of all, you should eject ejectable disks instead of unmount them.
Second of all, you can’t pass a list of System Events’ disk specifiers to a shell script.

Use the Finder


tell application "Finder"
	eject (every disk whose local volume is true and ejectable is true)
end tell

Interestingly ejecting doesn’t work properly for a partitioned WD My Book Studio (I don’t use their WD Smartware) because a dialog box pops up asking whether you want to eject all volumes or just the one being addressed.