How do I find the CD?

I’m writing a script to perform a few operations on a cd (extracting some data from it, etc)

Right now my script starts with:


tell application "Finder"
	set cd to choose folder with prompt "Please select the CD"

because I don’t know what the CD title (volume name) will be.

Is there a way to discover it from within the script?
I only have one cd drive.

This script will give the user a list of every mounted volume on the system to choose from:

tell application "Finder"
	set thisdisk to (choose from list (list disks)) as Unicode text
end tell

I hope this helps,

Thank you, that’s not bad.

I still hope someone knows how to tell wheter each disk in (list disks) is a CD.

As long as you have only one CD or DVD drive, the following should return the voume name:

do shell script "drutil status | grep '/dev' | sed 's/\\(.*\\)\\(Name: \\)\\(.*\\)/\\3/g'"
set cdName to (do shell script "df | grep " & result & " | sed 's/\\(.*\\)\\(\\/Volumes\\/\\)\\(.*\\)/\\3/g'")

HTH, Alex

That’s what I was looking for! I should have thought of it myself :stuck_out_tongue:

Since it is only for my personal usage, I’ve abbreviated it to

	set cd to (do shell script "df |sed -n '/^.dev.disk1/s!.*/!!p'")

The problem is you assume that the CD is always going to be disk1. This assumption holds only if you have only one hard disk, and if you do not attach another storage device (external drive, flash card, camera), before inserting the CD. Otherwise, your CD will be disk2, or disk3, etc. That’s why you need to get the mountpoint from drutil first.