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

Identify inserted recordable media type System
A reader emailed me a question; he wanted to know how to identify what sort of recordable media (CD-R, CD-RW, DVD-R, etc.) was in his machine's optical drive. Obviously, you could hit the eject button to answer the question, but I wondered if the system would be able to help. After a bit of testing, I found three ways to find this info, though I suspect there may be more.

The first solution is to use System Profiler (hold down the Option key, click the Apple menu, select System Profiler). Select Disc Burning in the Contents column, click on your optical drive in the Burning Device section of the window, and then look in the Media section below -- you'll see not only the media type, but also whether or not it's blank, erasable, overwritable, appendable, and the disc's available write speeds. This is the most-detailed information about the inserted media that I was able to find.

The second solution is to use Disk Utility, in Applications » Utilities. Select your optical drive in the sources list, and then look at the bottom of the Disk Utility window. Among the other items shown is Media Type, and that answers the question -- it will read CD-R, DVD-R, DVD-ROM, etc. based on what's inserted in the drive.

The final solution works in Terminal (also in Applications » Utilities). diskutil is somewhat like Disk Utility for the command line; it can provide a lot of information about the drives in your machine. First, though, you need to know the device ID for your optical drive. If you already know your optical drive's ID (let's say it's /dev/disk3), you can see what type of media is inserted by typing diskutil info /dev/disk3. In the output, you'll see an entry for Optical Media Type which tells you exactly what type of media is in the drive.

If you don't know your optical drive's device ID, read on for one way to find it using Terminal.

Assuming you've already inserted a blank disc of some sort, you can find your optical drive's device ID by running diskutil list | grep "0.0 B" in Terminal (the 0.0 B bit searches for discs with absolutely nothing stored on them). Alternatively, just type diskutil list and look through the output for a drive without any entry in the TYPE or NAME column (again, assuming it's a new, blank disc).

In either case, you're looking for the /dev/disknn (where nn is some number, typically only a single digit) value that appears in the left-hand column of the output. That's your device ID to use in the diskutil info command.

If you know of other ways of determining the type of inserted media, and/or an easier way to get the optical drive's ID, please post in the comments.
    •    
  • Currently 1.75 / 5
  You rated: 4 / 5 (8 votes cast)
 
[7,236 views]  

Identify inserted recordable media type | 8 comments | Create New Account
Click here to return to the 'Identify inserted recordable media type' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Identify inserted recordable media type
Authored by: fds on May 21, '09 07:56:39AM

drutil status



[ Reply to This | # ]
Identify inserted recordable media type
Authored by: blackxacto on May 22, '09 05:32:54AM

Beautiful. Works great.

---
You'll never know which way to look, which way to see us.



[ Reply to This | # ]
Identify inserted recordable media type
Authored by: wallybear on May 21, '09 08:18:27AM
You can use the system_profiler command from terminal:
Using

system_profiler SPDiscBurningDataType

you'll get something like this:
Disc Burning:

    PIONEER DVD-RW  DVR-216D:

      Firmware Revision: 1.06
      Interconnect: ATAPI
      Burn Support: Yes (Generic Drive Support)
      Profile Path: None
      Cache: 2000 KB
      Reads DVD: Yes
      CD-Write: -R, -RW
      DVD-Write: -R, -R DL, -RW, +R, +R DL, +RW
      Write Strategies: CD-TAO, CD-SAO, CD-Raw, DVD-DAO
      Media:
          Type: CD-R
          Blank: Yes
          Erasable: No
          Overwritable: Yes
          Appendable: Yes
          Write Speeds: 4x, 10x, 16x, 24x, 32x, 40x
Or, if you want only the Media info, use:

system_profiler SPDiscBurningDataType | sed -n "/Type:/,/*/ p"

and you will get:
          Type: CD-R
          Blank: Yes
          Erasable: No
          Overwritable: Yes
          Appendable: Yes
          Write Speeds: 4x, 10x, 16x, 24x, 32x, 40x
If you don't like Terminal, you can wrap the command in an Applescript like this one:
on run
	display dialog "Media in your optical drive:" & return & (do shell script "system_profiler SPDiscBurningDataType | sed -n '/Type:/,/*/ p'") buttons "Ok"
end run

and save it as an application for your convenience.

That's it.

[ Reply to This | # ]
Identify inserted recordable media type
Authored by: wallybear on May 21, '09 02:49:50PM
Using this modified script the info dialog will show also the correct disk icon for the inserted media:
on run
	set disktype to do shell script "system_profiler SPDiscBurningDataType | grep 'Type' | sed 's/^.*Type:.//g'"
	
	if disktype contains "CD" then
		set iconfile to "/System/Library/Extensions/IOCDStorageFamily.kext/Contents/Resources/" & disktype & ".icns"
	else if disktype contains "DVD" then
		set iconfile to "/System/Library/Extensions/IODVDStorageFamily.kext/Contents/Resources/" & disktype & ".icns"
	else if disktype contains "BD" then
		set iconfile to "/System/Library/Extensions/IOBDStorageFamily.kext/Contents/Resources/" & disktype & ".icns"
	else --generico
		set iconfile to "/System/Library/Extensions/IOCDStorageFamily.kext/Contents/Resources/CD.icns"
	end if
	
	display dialog "Media in your optical drive:" & return 
		& (do shell script "system_profiler SPDiscBurningDataType | sed -n '/Type:/,/*/ p'") 
		buttons "Ok" with icon POSIX file (iconfile)
end run

(the "display dialog" line is broken in three lines for better readability)

[ Reply to This | # ]
Identify inserted recordable media type
Authored by: chrischram on May 24, '09 01:22:10AM

Just my luck: The first disc I tried this script on was type DVD-ROM. My System has no .icns file for that type. My quick and dirty fix was to wrap the "display dialog" line into a "try/on error/end try". Under the error condition I simply display the dialog without the icon.



[ Reply to This | # ]
Identify inserted recordable media type
Authored by: wallybear on May 25, '09 02:37:13AM
True. I forgot a filter in the first statement also a CD-ROM would give an error. First line should read like this:
	 set disktype to do shell script "system_profiler SPDiscBurningDataType | grep 'Type' | sed -e 's/^.*Type:.//g' -e 's/-ROM//g'"

Anyway, it's a good idea to enclose the icon selection in a "try/on error/end try" clause. And I added the detection of no media inserted. Here is the updated script:
on run
	set disktype to do shell script "system_profiler SPDiscBurningDataType | grep 'Type' | sed -e 's/^.*Type:.//g' -e 's/-ROM//g'"
	try
		if disktype contains "CD" then
			set iconfile to "/System/Library/Extensions/IOCDStorageFamily.kext/Contents/Resources/" & disktype & ".icns"
		else if disktype contains "DVD" then
			set iconfile to "/System/Library/Extensions/IODVDStorageFamily.kext/Contents/Resources/" & disktype & ".icns"
		else if disktype contains "BD" then
			set iconfile to "/System/Library/Extensions/IOBDStorageFamily.kext/Contents/Resources/" & disktype & ".icns"
		else --generic
			set iconfile to "/System/Library/Extensions/IOCDStorageFamily.kext/Contents/Resources/CD.icns"
		end if
	on error
		set iconfile to "/System/Library/Extensions/IOCDStorageFamily.kext/Contents/Resources/CD.icns"
	end try
	set diskinfo to (do shell script "system_profiler SPDiscBurningDataType | sed -n '/Type:/,/*/ p'")
	if diskinfo is "" then set diskinfo to "No media found."
	display dialog "Media in your optical drive:" & return 
		& diskinfo buttons "Ok"  default button 1 with icon POSIX file (iconfile)
end run


[ Reply to This | # ]
Identify inserted recordable media type
Authored by: BulbVivid on May 21, '09 09:56:41AM

Go to DeviantART or Interfacelift or similar site and find disk icons with labels (like Pry Hardware by Jonas Rask), then use CandyBar or a similar application to change the disk icons. Then the loaded media can be identified by the label on the icon.



[ Reply to This | # ]
Identify inserted recordable media type
Authored by: wallybear on May 21, '09 01:52:07PM

OS X has already the proper icons for each kind of optical disk, they are stored in IOCDStorageFamily.kext, IODVDStorageFamily.kext, IOBDStorageFamily.kext (for CD, DVD and BlueRay disks, respectively) located in /System/Library/Extensions. Finder use them when you mount the disk and they are more legible than the Pry Hardware one (Pry icons have really tiny labels on the disk icons).

But this does not solve the problem, as those icons are used only if you mount the disk in Finder. If you choose to ignore the blank disk (say you want to use Toast or Burn or anything you like), you need something else like the two CLI commands above (drutil or system_profiler).



[ Reply to This | # ]