URL scheme to open any file, any app, or any file with any app

Hey,

a not-so-power-user contact was frustrated that they couldn’t link to files easily and have the default app open the linked file.

While file:// works, that reveals the file in Finder only.

I was nerd sniped by this and created a little open source tool:

OpenAny.app

It exposes the openany:// URL scheme and can be used for “open file X with app Y” in its most complex invocation:

  • openany://app/com.apple.textedit
    → launches TextEdit via its bundle identifier.
  • openany://file/open?path=/path/to/file.txt
    → opens /path/to/file.txt in your default editor of text files.
  • openany://file/open?url=file:///path/to/file.txt
    → opens /path/to/file.txt in your default editor of text files, but using a file:// URL instead of a path.
  • openany://app/com.apple.textedit/view?path=/path/to/file.txt
    → opens /path/to/file.txt in TextEdit.
  • openany://app/com.apple.textedit/view?url=file:///path/to/file.txt
    → opens /path/to/file.txt in TextEdit, but using a file:// URL instead of a path.

The most power user thing I can think of is that you can now create links in your plain text note-taking/Zettelkasten/… app of choice to launch files and apps.

fNo need to use Spotlight anymore, or the mouse, as long as you can invoked the link with a keyboard shortcut :smiley:

E.g. this would launch Marked to preview a file and TableFlip to edit its tables:

Preview:     <openany://app/com.brettterpstra.marked2/view?path=~/document.md>
Edit Tables: <openany://app/de.christiantietze.TableFlip/view?path=~/document.md>

... document goes here ...

Apps that fold away the link URL work best for this, of course!

If you want to check that out, you can find the downloads here:

I consider this to be beta software and want to test it a bit more, esp. if the URL scheme formats make sense or could be shortened, maybe.

If this tool arrives in your toolbox and makes something work, tell me about it!

Someone requested Shortcuts support, which I imagine could be used to create links based on Finder selection? Not sure.

Cheers!

10 Likes

IMHO using bundle identifiers is non-intuitive. The app idea is good, but I probably wouldn’t use it as often (or I’d need additional programming on my side) as I wouldn’t remember the bundle identifiers.

FYI, this was posted by one of the developers of at least two well-designed apps for the Mac The Archive • Zettelkasten Method and TableFlip - Simple Table Editor. :innocent:

4 Likes

An easy way to find app bundle ids is to run this from the command line:

osascript -e 'id of app "Finder"'

Where you would replace “Finder” with the application of interest.

4 Likes

I was this many years old when I discovered TableFlip! Take. My. Money…

That’s good info - thanks!

That said, I still have no desire to go look that up when I’m creating a link. And if there’s an easy way to query it based on the app name, ideally that easy way would be built into the app’s URL parser. :slight_smile:

Hm… @ctietze – it should be possible to use that bit of shell script to turn an app name to a file identifier behind the scenes

I tried a couple of lookups manually.

For example, “NotePlan” returned “co.noteplan.NotePlan3.”

But I got errors with “Bridge” and “Adobe Bridge.” It wasn’t until I submitted “Adobe Bridge 2024” that I got the unintuitive response of “com.adobe.bridge14.”

So automating via script is still a bit tricky.

True. But 75% of the way there is still 75% of the way there

And I would add a wildcard search in the Applications folder in an attempt to locate the proper form of the app name.

The OP did say “I consider this to be beta software.” :slightly_smiling_face:

1 Like

Yup! Just making suggestions. If it were written in Python, I would try to write it in myself and make a pull request… but I barely know any Swift.

I made a vary simple PopClip extension that when an application name is selected it puts the bundle ID on the clipboard.

1 Like

Can you share that? I assume it’s a PopClip snippet?

Thanks for all the feedback!

Sorry the README doesn’t do a good job and I forgot to mention here:

You can drag an .app onto the OpenAny app to discover app identifiers. It works with multiple apps, too.

It’s still not ideal, and it kind of assumes that you only do it once and remember this, which is unrealistic :slight_smile: But it’s a built-in way to discover app id’s for now.

– I’m not a heavy Shortcuts user. I guess someone here is and can help :slight_smile: Because I wonder this:

Would a Shortcuts (App Intent) help and and make sense to select an app and a file to produce these openany:// links for you?


@MevetS’s osascript approach is a great idea. If AppleScript can do it, there’s probably a built-in way to do that, too, somehow, without a (slow) round-trip to AppleScript.

1 Like

Oh yes: In the spirit of 75%, allowing an app name and then selecting the first match from ~/Applications and then /Applications would probably do the trick and help with weird official but internal app names (that differ from the .app bundle you see in Finder, like the Adobe Bridge example I guess)

I’ve built and uploaded v1.1.0 to GitHub to make e.g. openany://app/TextEdit work:

3 Likes

Had a quick play, its a nice idea. Hookmarks does the same thing, among other stuff, so its not something I need myself. But Hookmarks is expensive and if you just need the launch from a link aspect and nothing else, this’ll do the job,

i can not get the drag and drop of applications working as described on the GIT pages. Maybe I am doing something incorrect

Open “OpenAny” app
drag app from applications folder onto the menubar icon

MacBook Pro - intel
12.7.2

Is this not exactly what the little app Hookmark does?

Is this not exactly what @nfdksdfkh said?

:slight_smile:

Choice is good.

Sure. I actually did it as package, copying an existing package and modifying it, but here is the snippet version (which I had to learn how to do, much simpler!).

#popclip 
name: GetBundleID
icon: symbol:questionmark.app
interpreter: zsh
shell script: osascript -e 'id of app "'$POPCLIP_TEXT'"' | pbcopy

Enjoy!

1 Like