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


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: 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 | # ]