How do I find the application name to open a file using AppleScript?
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" =&gt; "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" =&gt; "PaintCode Trial"