1

I find the AppleScript method of opening a file convenient but often cannot guess at the application name to use when I do not want the default options.

As an example, I have installed Foxit PDF Reader to directly annotate a PDF. I have not been able to guess what to use in the open -a ??? my.pdf command.

How could I find this for any general application? Perhaps there is some way to get a list of all available options?

  • It's simply: open -a "Foxit Reader" /path/to/file.pdf – user3439894 May 18 '16 at 17:02
  • @user3439894, this resolves my example case but Mateusz's answer identifies how to apply this to the general case. There are many applications I want to do this with and I do not want to ask a new question for each one. – Steven C. Howell May 18 '16 at 18:00
  • As I never have to worry about Localization, I personally have no need to get the BundleIdentifier as I can plainly see the name of the Apps and all work of me as in the example I previously presented. Anyway, building on what Mateusz Szlosek presented, if you want to get all of the app names and BundleIdentifier in a nice list, just use the following command line. Copy and paste it into Terminal: for f in /Applications/*.app; do echo "${f##*/} =>" "$(plutil -p "$f/Contents/Info.plist" | awk -F'[""]' '/BundleIdentifier/ {print $4}')"; done – user3439894 May 18 '16 at 21:27
3

You can use -b option and use Bundle Identifier instead of using Application name. For example, to get Bundle Identifier from Safari:

plutil -p /Applications/Safari.app/Contents/Info.plist | grep BundleIdentifier

as a result You'll get "CFBundleIdentifier" => "com.apple.Safari"

Then You use it like this:

open -b com.apple.Safari /path/to/file

Generally, You'll need to get Bundle Indentifier from Info.plist file located inside Application.app/Contents/ directory.

Or if You want, You can get the app name with this:

plutil -p /Applications/PaintCode\ Trial.app/Contents/Info.plist | grep BundleName

output:

"CFBundleName" => "PaintCode Trial"
  • This does seem a viable alternative. These Bundle Identifiers will be more difficult to remember and longer to type. For Foxit, the Bundle Identifier is com.foxitsoftware.FoxitReaderLite. If there is not a way to get the shorter application name, a bash alias for this would probably be the next best option, i.e., alias foxit="open -b com.foxitsoftware.FoxitReaderLite". – Steven C. Howell May 18 '16 at 16:36
  • @stvn66 I've added the info about getting the app name in my answer. – Mateusz Szlosek May 18 '16 at 16:40
  • Why go through so much rigamarole when simply open -a "Foxit Reader" /path/to/file.pdf does what the OP is asking!? – user3439894 May 18 '16 at 17:05
  • Because some apps have different display name than bundle name. For example it could be Localized. – Mateusz Szlosek May 18 '16 at 17:06
  • Good point! +1 :) – user3439894 May 18 '16 at 17:28

You must log in to answer this question.

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