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