How to link a local file in Obsidian?

How to link a local file in Obsidian?
Like a csv file being located on file:////Users/bruno/Dropbox/Obsidian\ Vaults/ClippingContents/statswords.csv
Usually with image or pdf, we would have This is an Image, therefore how to get that csv file location in Obsidian.
Thanks

5 Likes

markdown link will work for you: [filename](file:///<absolute-path>)

for your case it would be [statswords.csv](file:///C:/Users/bruno/Dropbox/Obsidian/Vaults/ClippingContents/statswords.csv)

Note that any whitespace in the path should be replaced by %20

13 Likes

Also, you can simply type [[ and then start entering filename if it’s below Obsidian vault in the folder structure.

1 Like

I have tried and it does not seem to work, even though tried to get that file in the vault (either xlsx or csv file) they are both not taken in.
Thanks

2 Likes

Is there a proper way of doing this, because it works whether I use back slashes or forward slashes in everything after file:///. For example, both of these work:
file:///D:\film\filmname.mp4 and file:///D:/film/filmname.mp4

I just want to ensure that I won’t have to go through all my files later and replace slashes.

2 Likes

I tried to apply the answers in this thread to create a link in Obsidian to an external, local file on my hard drive but unfortunately I couldn’t get it to work. I was careful to check all the things I might be doing wrong but I just could’t get it to create a link. The file is an MP4 file on a local, internal hard drive. Ideally I wanted to create a link to the enclosing folder. I guess I will keep looking and trying to learn more in hopes of figuring it out. Thanks.

1 Like

I have managed to make this sort of work but most of my files and folder names have got spaces in them so need the %20 adding.

Is anyone aware of an easy way to create a URL with the space code already in it? I am on a Mac.

2 Likes

I use Service Station for this. It can add custom scripts to the Finder right-click menu. So I have a little script that grabs the filename and url-encodes it into an Obsidian-format link.

I also use that same script in an Alfred workflow, so I can do the same thing for any file/folder that I search for in Alfred.

Here’s a link to a gist of my script, in case anyone wants to borrow it.

2 Likes

You don’t have to replace spaces if you enclose your path in <> :

[Text](<file:///path to file.pdf>)

37 Likes

Hello Nebulous,

What has been working flawlessly for me is this format:

[Local file - Dr Charles Hoffe - Lytton BC Video Interview](<file:///Y:\Covid\Canadian Doctor Defies Gag Order - Tells Public How Moderna COVID Shots Killed and Disabled Patients-vdil0d.mp4>)

The text between the two square brackets is only a description of the file I’m linking to, and I always add "Local file - " at the beginning of the description so that I know what links are local files. I’m fairly new to Obsidian, and I’m adding the "Local file - " descriptor just in case that I discover later on that I can’t distinguish between different types of links. For now it seems pretty obvious which is which, but I want to future-proof just in case.

It is extremely irritating that mousing over the link doesn’t pop up a view of the underlying link, or show the underlying link on the bottom statusbar. This should be core functionality within Obsidian.

Anyway, then as you can see, the part between the parentheses is where the linking magic happens. Make certain to have the “<” sign after the first parenthesis, and “>” just before the last parenthesis. After “<”, you put in “file:///”, and then the full link to the filename.

As you can see from my example above, I have spaces in the filename, but the link works just fine without the “%20” fillers for the spaces. Maybe that’s just something with my system, if you find that the link is not working, try a quotation mark just before the drive letter, and another at the end of the filename (after the extension, I would think would be better). And if still not working, try to fill in the spaces with "%20"s, like this for example (with, and without the quotation marks encapsulating the complete filename):

[Local File - Covid Early Treatments](<file:///Y:/Covid/HTMLs/MATH+%20Protocol%20FLCCC%20Front%20Line%20COVID-19%20Critical%20Care%20Alliance.htm>)

Something here should work.

15 Likes

Is there a solid way to add a file link thru a relative file path? This is really important for cross-computer consistency.

8 Likes

This may not be exactly what you are after, but the below allows me to link to files on a network share instead of the local device:
[Pitch Deck](<file:///\\Ares-II\Content\Mark\Sync\Reading\Venture\Pitch Deck.pdf>)

  • “Ares-II” is the server name (using SMB share between Windows & NAS)
  • Encapsulating the path in <> allows for spaces in the path without having to insert %20
4 Likes

Hi guys, finally I worked this out. Actually, Obsidian file link mechanism just follows the rules of markdown file standard, you can refer to this Q&A in stackoverflow: hyperlink - How link to any local file with markdown syntax? - Stack Overflow, and also I tried ways they discussed, finally I found a good one to achieve my goal, it is pretty simple, just make it like this:
[YourDocument](<…/…/Doc/YourDoc.pdf>) . This works in obsidian and also if you hover your mouse on it there is also a preview effect.

4 Likes

If the file is located outside the vault, [YourDoc](<.../.../dir/YourDoc.pdf>) will not work, not as well as previewing.

[YourDoc](<file:///C:/dir/YourDoc.pdf>) works as hyperlink, but not being able to preview.

thanks for sharing

5 Likes

I haven’t tried the case that the linking file is outside the vault folder, because the vault folder is in a cloud drive that is able to sync across different computers. If the local link is hardcoded as an absolute directory, you have to ensure all your sync dirs have the same location at different working pc, it is really big trouble to me.

Try that format @alexdai, for example, [MyGlobalSettings](<file:///U:!PRBackups\Profiles\Global.con>)

Brackets with whatever name you want to call it inside the brackets, then (<file:/// and the full filename, drive letter and all, finish with >).

Go into Preview mode and click on your link, it should work.

3 Likes

I go into a browser, create a new tab, do File:Open, navigate to the desired directory, open any file there. In the URL you’ll see the entire path. You can copy that path and paste it after “file:///”. If you want to point to a directory, use the same process but delete the filename at the end of the URL.

4 Likes

The link to the file is a URL, so use forward slashes because that is the standard format. The back-slash is a Windows thing, and although it will work on a Windows PC, it may cause problems on other devices.

2 Likes

This is the best solution IMO especially when you are dealing with connecting local files not necessarily inside the Obsidian vault.

1 Like

Thank you for putting time into this! I’m planning to set it up this week and tweak my workflow a bit. My goal is to use Obsidian to manage my production projects better and be able to initiate folders/files from Obsidian and link to session files on external drives. For my use case it will be nice to maintain a nice library/DB of sorts for tracking completed songs, writer/publisher splits, placements, and where they were used, etc. What you created saves a ton of time!

1 Like