Get Bundle ID

A little AppleScript macro to quickly retrieve the Bundle ID of an application (CFBundleIdentifier, as found in the Info.plist):

Notes:

The “Refresh Database & OK” button refreshes the LaunchServices database for apps. In every-day live you don’t need to do that. It is meant for cases when an installed app is not found by the script.

The refresh is harmless, it will not reset the LS database, however the refresh can take 30 seconds or more.

If after a refresh an installed app still isn’t found, the LS database most likely has a problem. In that case you can consider a reset of the database, by running this in the Terminal:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -r -kill -all user,local,system

With a reset you will loose your customized document/application associations.


Get Bundle ID.kmmacros (2.6 KB)

4 Likes

@Tom, here is a much simpler script that gets the job done.

I don't do any error checking for apps that aren't installed because the simple purpose is to get the BundleID of an app that you do have installed.

set targetApp to "BBEdit"

set bundleID to get id of application targetApp
return bundleID

-->com.barebones.bbedit

Thanks, Michael. That’s exactly the same, without dialog window :wink:

Yes, no need. If the app is not in the LS database you just get no bundle ID returned. As mentioned on your thread, usually you get the “Choose Application” window then. (Which can come in handy: if you’ve made a typo you can still select the app from the list.)

1 Like