I have an app name foo.app I want to open from command line (using open).

My folder structure is like this:

     +--- foo.app
     +--- foo.app

I want to open the app located in the bar folder, however if I do open -a foo.app, the app located in the baz folder will open, even if my current working directory is in the bar folder.

open -a ./foo.app or open -a ~/bar/foo.app doesn't work either.


In this case, open -a is NOT what you want; the -a option is for launching known applications (indexed in the Launch Services database that lets you open a document and get the right application) by name, not by pathname, or for opening files with a given application.

What you are looking for is just plain opening foo.app, just like you double-clicked it in the Finder. To do that,

open foo.app

This will open exactly that application, without involving the Launch Services database at all.


open bar/foo.app/Contents/MacOS/foo

If you're using the -a parameter to open, then you need to omit the .app extension.

  • It doesn't matter if I omit the .app extension and what if the executable is not named foo? How would I get the executable name? Example :bar/foo.app/Contents/MacOS/foobar – Tyilo Feb 5 '12 at 1:02
  • Typically the .app bundle and the actual executable file (in the Contents/MacOS/ directory) have the same name. So if the top-level directory is named foo.app, I would expect the executable file to be foo.app/Contents/MacOS/foo . – bneely Feb 5 '12 at 1:06
  • But in this case it doesn't... – Tyilo Feb 5 '12 at 1:24
  • Then you will need to go into the .app directory and determine the name of the executable file in order to type the correct open command. How did you obtain these apps? – bneely Feb 5 '12 at 2:07
  • It's a jar bundled inside an app so the executable name is actually JavaApplicationStub. I also found out that the executable name is stored in the Info.plist as CFBundleExecutable. – Tyilo Feb 5 '12 at 2:39

You must log in to answer this question.

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