Test for existence of Spotlight/QuickLook plug-ins?

I think the answer to this question is “no,” but I thought it was worth asking.

Can Applescript directly detect the presence of a Spotlight or QuickLook plug-in, or do I have to check for the existence of the plug-in file in the /Library/Spotlight or ~/Library/Spotlight folders (or the matching folders for QuickLook)?

Thanks for any advice on this one.


You could use the «qlmanage» command with the p flag to detect available Quick Look generators:

set qlgenerators to my getqlgenerators()

-- I am returning a list of qlgenerators
on getqlgenerators()
	set tmpfilepath to my gettmpfilepath("tmp")
	set command to "qlmanage -m 2> " & quoted form of POSIX path of tmpfilepath
	do shell script command
	set filecont to paragraphs of (read (tmpfilepath as alias))
	set qlgenerators to {}
	repeat with para in filecont
		if para contains " -> " then
			set qlgenerator to (characters 3 through -1 of para) as text
			set qlgenerators to qlgenerators & qlgenerator
		end if
	end repeat
		do shell script "rm " & quoted form of POSIX path of tmpfilepath
	end try
	return qlgenerators
end getqlgenerators

-- I am returning a path to an unused temporary file
on gettmpfilepath(suffix)
	set tmpfolderpath to (path to temporary items folder from user domain) as text
		set randnum to random number from 10000 to 99999
		set tmpfilepath to tmpfolderpath & randnum & "." & suffix
			set tmpfilealias to tmpfilepath as alias
		on error
			exit repeat
		end try
	end repeat
	return tmpfilepath
end gettmpfilepath

Thank you for that - it looks ideal for the purpose, but the posted code gives me an “end of file” error at the line that begins “set filecont…”

Is there a similar command for Spotlight? The command “mdutil” doesn’t seem to handle this problem, but perhaps I am not seeing something obvious.