Can one determine the extensions that invoke a particular app?

I am able to find out what the default app is for a particular file extension.

Is there a way to look at a particular app and determine the list of file extensions that invoke it as the default app (i.e. the reverse)?

I suspect that there likely isn’t a method for doing this quickly, but I won’t know if I don’t ask.

You could read the application’s Info.plist file and then look at the CFBundleDocumentTypes key values to see the types of documents the app will open.

Thank you for the suggestion. I wasn’t aware that this was always possible. Will have a go at that.

I had a look at the Info.plist is the bundle itself. Is this the instance you meant?

For something like my app, there is a section “Information Property List”>“Document Types (array)” that appears to be a list of keyed lists. “Item 0” (dictionary)>“CFBundleTypeExtensions (array)”>“Item0” (String) is currently showing “*”.

I remember in Script debugger you can set the types of files the app handles. Is this item 0 that is currently “*” set by compiling the script with that compiler blank filled in?

If so, I need to fill it in first and then I can search for it in the dictionary. … I think. :>)

The “*” file type is a wildcard that matches any type of file. You can change it to something like “jpeg” to match files with that filename extension. The array allows there to my multiple file types: “jpg”, “jpeg”, “png”, etc.

Mark;

I’m using the following code to allow access to the user defaults.

	if my id = missing value then error "This code works only in an applet or script bundle."
	if current application's id = my id then -- must be running as applet
		set theDefaults to current application's NSUserDefaults's standardUserDefaults()
	else -- being run by editor or other host app
		set myPath to POSIX path of (path to me)
		set theData to current application's NSData's dataWithContentsOfFile:(myPath & "Contents/Info.plist")
		set infoDict to current application's NSPropertyListSerialization's propertyListWithData:theData options:0 format:(missing value) |error|:(missing value)
		set myID to infoDict's objectForKey:"CFBundleIdentifier"
		set theDefaults to current application's NSUserDefaults's alloc()'s initWithSuiteName:myID
	end if
	
	-- This reads a value for a key and returns it via the method objectForKey.
	set theValidExtensions to theDefaults's objectForKey:"CFBundleDocumentTypes"

However; this appears to work only if the value for a key is changed. I believe that Shane’s book noted that a value doesn’t get loaded into the internal database unless it is changed from the plist file defaults.

As such; I assume that I need to take the same approach as if I were running in an editor and initially read the plist file directly. That’s fine, if all I need to do is find out a value. If I need to write it (and possibly re-read it), I think I need to register it (which loads it into the internal database). That way; if I change it in the internal database, it will be re-written to the plist file and persist between runs.

Am I making any sense here?

Info.plist entries aren’t meant to be modified. It’s fine for a script app, but otherwise you risk breaking the app’s code-signing.