Asking the system for an app's bundle identifier knowing only its name

The NSWorkspace method that does this, fullPathForApplication, is deprecated. So what's the alternative? I do note that oascript can do it by id of app "App Name", so unless that's going away too, there must be some way of doing it, no?

Answered by kithrup in 697035022

Ah ha!

MDQuery, searching for kMDItemDisplayName and/or _kMDItemDisplayNameWithExtensions should do the trick. I haven't written the code for it yet, but that should do the trick.

(I realize I could look in /Applications and /System/Applications, but on macOS an app can be in other locations and still be usable. And, I'd also kinda like to know what happens if there are multiple matches for it on the system. This seems like the kind of thing Launch Services would handle, but a medium-length check didn't show anything.)

Accepted Answer

Ah ha!

MDQuery, searching for kMDItemDisplayName and/or _kMDItemDisplayNameWithExtensions should do the trick. I haven't written the code for it yet, but that should do the trick.

Asking the system for an app's bundle identifier knowing only its name
 
 
Q