How to handle bundle identifiers with spaces? Lets assume my current directory is /Applications and it contains all my apps. Lets say I want to know the bundle identifier for Google Chrome:

$ mdls -raw -name kMDItemCFBundleIdentifier 'Google Chrome.app'
com.google.Chrome


Now let’s use that to locate the app:

$ mdfind kMDItemCFBundleIdentifier = com.google.Chrome
/Applications/Google Chrome.app


Now lets try the same for Tor Browser Bundle. First, get the bundle identifier:

$ mdls -raw -name kMDItemCFBundleIdentifier TorBrowser.app
org.mozilla.tor browser


Then, locate the app:

$ mdfind kMDItemCFBundleIdentifier = org.mozilla.tor browser


Nothing. I likely need to quote it:

$ mdfind kMDItemCFBundleIdentifier = 'org.mozilla.tor browser'


Nope, still nothing. Lets try something else:

$ mdfind kMDItemCFBundleIdentifier = 'org.mozilla.tor'
$ mdfind kMDItemCFBundleIdentifier = "org.mozilla.tor browser"
$ mdfind kMDItemCFBundleIdentifier = org.mozilla.tor\ browser
$ mdfind kMDItemCFBundleIdentifier = "org.mozilla.tor\ browser"
$ mdfind kMDItemCFBundleIdentifier = 'org.mozilla.tor%20browser'
$ mdfind kMDItemCFBundleIdentifier = 'org.mozilla.tor+browser'
$ mdfind kMDItemCFBundleIdentifier = 'org.mozilla.tor_browser'


Nothing works. This is the only app I ever had this issue with, and the only one I ever saw with a space in its bundle identifier. How can we reference it?
A proper bundle identifier should not have a space in it. According to Apple's App Distribution Guide -> About Bundle IDs, a


  "...bundle ID string must be a uniform type identifier (UTI) that contains
  only alphanumeric characters (A-Z,a-z,0-9), hyphen (-), and period
  (.). The string should be in reverse-DNS format. For example, if your
  organization’s domain is Acme.com and you create an app named Hello,
  you could assign the string com.Acme.Hello as your app’s bundle ID.


So, technically, org.mozilla.tor browser is not a valid bundle identifier, so you'll get unexpected results when trying to work with it. It should likely be changed (by the developer) to something like org.mozilla.tor.browser or org.mozilla.tor-browser, etc.