AppleScript – How to Find Application Name to Open a File

applescript

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?

Best Answer

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"