Well, this script saved me sometimes - so I’d like to share it. The purpose is simple: Sometimes you may run into a situation where something went wrong while mounting or ejecting a CD/DVD/etc. You are left with no Volume mounted on the desktop but the media stuck in the device. The eject-key on the keyboard wouldn’t work… at least this happens to me once in a while.
set d_list to do shell script "drutil list"
set d_cont to paragraphs 2 thru (number of paragraphs in d_list) of d_list
set device_list to {}
repeat with i in d_cont
set this_i to (i as text)
if number of words in this_i > 2 then
set device_list to device_list & (word 3 of (i as text))
end if
end repeat
set choice to choose from list device_list with prompt "Eject media from which device?" without multiple selections allowed and empty selection allowed
if (class of choice = list) then
repeat with i from 1 to (number of items in device_list)
if ((item i of device_list) as text) = ((item 1 of choice) as text) then
do shell script "drutil tray eject " & i
exit repeat
end if
end repeat
end if
I’m not sure if this works with other devices than my built-in Apple-DVD-burner as I have no additional hardware to test it.
I would appreciate any comments, rants, error-reports or whatever.
Model: PowerMac G5 2.3GHz Dual
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)