Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.