2

I am building a webpage that indexes files on my system (macOS). I would like to be able to add two hyperlinks to each file, one which a) opens the file, and one which b) reveals the file in the finder.

Regarding a), I can open a file with the following URL:

file://…

However, this displays it in the browser window, whereas I would prefer to open it in the default application. So not quite what is needed.

Regarding b), I have no idea if such a URL scheme exists, but would appreciate it if anyone knows how to achieve this.

I have been able to achieve it by passing the file path to Keyboard Maestro and then using a macro to open / reveal the file. However, I would prefer to achieve this without any intermediate application.

Andy
  • 31
  • 1
  • 3
  • Ah, that edit changes everything. You can list URL schemes with [`lsregister -dump`](http://superuser.com/q/498943/). You may be able to create a custom handler based on [this question and its answers](http://superuser.com/q/548119/). Maybe [this](http://hublog.hubmed.org/archives/001154.html) works for you? (Please reply with @slhck) – slhck Feb 09 '17 at 11:48

1 Answers1

1

The file:// path is generally just file:// and then the files path.

One way to do it in Finder is to right-click the file then press "Get Info", or select the file and Command + I (shortcut) to bring up the files information.

You can find the file's path next to "Where:" (under General). You can just copy that (Command + C or Edit > Copy) and paste that (don't worry, it will be copied as a UNIX path (e.g /users/Name/My Folder)

Now, in your browser you can just type: file://(paste in the path you copied)/files name

edit: Someone edited your question so now i'm not too sure what your intention is.

KamilDev
  • 136
  • 5
  • This is the original question of the author: http://superuser.com/revisions/1176559/1 – I guess your answer refers to the "wrong" interpretation. – slhck Feb 08 '17 at 11:44