Zettelkasten Forum


[FEATURE REQUEST] Link to a file in a note

Dear Christian and Sascha,
as far as I can tell, at the moment it's not possible to create a clickable link to a (non-txt) file on my computer within a note. Through drag&drop the location of the file on my computer will be created in the note, but just as plain text, it's not clickable. Even if I add the syntax "![](file location)" I can't open the file through clicking on the location text.
Are you planning to change this in the future?
Best wishes,
Vinho

Comments

  • Well, I do have an open task to deal with file-system links differently in the future. When the new Markdown highlighter is ready, I think it's time to tackle that. Will take some time, though.

    Author at Zettelkasten.de • https://christiantietze.de/

  • In the meantime, if you need a clickable link in The Archive, you can insert a file:/// link to the file instead of just the file path. They are basically a URL-encoded version of the file path and look something like this:
    file:///Users/basil/Desktop/Screenshots/Screen%20Shot%202018-12-03%20at%2008.58.51.png
    (for the file /Users/basil/Desktop/Screenshots/Screen Shot 2018-12-03 at 08.58.51.png)

    When you click on such a link in The Archive, the file is not opened directly, but it is revealed in Finder. A quick ⌘↓ (or ⌘O) then opens the file.

    Of course, creating these links by hand would be pretty tedious. Fortunately, there is (like for many other problems) a Keyboard Maestro based solution:
    Copy encoded URLs of selected files

    These links do not only work in The Archive, but in almost all other applications as well. I often include such links to files (or folders) in OmniFocus tasks, calendar events, etc. and find them immensely useful.

    If you like The Archive's "PrettyFunctional (Basic)" theme, consider upgrading to the "PrettyFunctional (Regular)" theme.

  • Thanks, Basil – that is a very helpful post!
    If I understand correctly, the file:/// link just works if there are no spaces in the file name or if you fill those spaces with %20 every time. That is indeed very tedious. I haven't used Keyboard Maestro so far and probably wouldn't buy it just for this purpose, but thanks for letting me know about this option.

    In the meantime, I have also learned about the option to put files into the "media" folder in my archive and then link to them with ![](media/filename), which would be a relative link that would also work on other devices.
    Again, the file name can't have spaces.

    Thanks a lot!

  • That's basically the trick: to "HTML-URL-encode" the path, which includes replacing spaces with %20.

    URL encoding the text or file from the clipboard can be automated with various tools.

    A combination of "take the selected file from Finder" and "make it a file:// URL":
    https://stackoverflow.com/a/9617705/1460929

    You can put this into a new Service in Automator and then assign to it a shortcut from System Preferences > Keyboard (instructions]. Et voila! No Keyboard Maestro needed, even though KM is great :)

    Author at Zettelkasten.de • https://christiantietze.de/

  • That's great, thanks!

Sign In or Register to comment.