Eject disk if inserted media is blank with applescript

109 Views Asked by At

I am hoping to create a custom applescript that will automatically eject my optical drive if the inserted cd is blank. I'm new to applescripts, and would greatly appreciate some input on how to find the answer.

I've currently created the array

set diskName to "disk2"
tell application "Finder"

end tell

where disk 2 is my optical drive... I've been able to eject the drive if any media is present, ive figured out how to mount the cd if any media is present, but I can not seem to figure out if it is even possible to index the media and then eject if no data is present.

Thanks in advance for any input or advice!


I believe I've figured out some sort of solution

set r to do shell script "/usr/bin/drutil status"

set diskName to "disk2"

if r contains "No Media Inserted" then

    do shell script "drutil tray eject"

end if

if r does not contain "No Media Inserted" then

    if r contains "blank" then

        do shell script "drutil tray eject"

    else

        tell application "iTunes" to activate

    end if

end if
1

There are 1 best solutions below

3
On

I really don't see the point in this, all the time you are warned when you insert a blank disk.