6

I am looking for a way to find an app's location on the system from the command line using its bundle identifier. I can open it like this:

open -b 'com.zerotier.ZeroTierOne'

... where com.zerotier.ZeroTierOne is my bundle ID, but what I want to do is locate where the app is actually installed. I want a command that will return (for example):

/Applications/ZeroTier One.app

in response to a query by identifier 'com.zerotier.ZeroTierOne'.

The "-R" option to open will reveal in finder but I want this to be completely non-interactive and done via a shell script.

14

The magic command is:

mdfind kMDItemCFBundleIdentifier = "com.zerotier.ZeroTierOne"

You can determine this by working backwards from mdls foo | grep kMDItemCF

So if you didn't know iPhoto's CF Bundle Identifier:

Mac:~ me$ mdls /Applications/iPhoto.app | grep kMDItemCF
kMDItemCFBundleIdentifier           = "com.apple.iPhoto"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .