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.

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"
  • Is there an equivalent API in Foundation for this?
    – mservidio
    Mar 9, 2017 at 18:41
  • 1
    @mservidio I have answered that question on StackOverflow because it is programming-specific
    – Ky.
    Sep 4, 2018 at 19:43
  • 1
    @AdamIerymenko (thanks for ZeroTier btw!) You don't need the extra pipe to grep: mdls -name kMDItemCFBundleIdentifier -raw "/Applications/Google Chrome.app" works.
    – luckman212
    Oct 14, 2020 at 3:48
  • Which one applications is default by open command with -b bundleId?
    – mqliutie
    Jul 22 at 3:48

You must log in to answer this question.

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