# How do I create an link to a folder?

I am trying to create a link to a folder such as

C:\Program Files (x86)\7-Zip

I have tried to use href, but as I understand that automatically appends a .pdf to the end.

I tried the solution in hyperref: How to open a directory view with href{...}?

but no success there either. The documentation http://www.tug.org/applications/hyperref/manual.html seems to imply that \url{} can be used for paths. But this just generated a text version of the url.

What is the correct method for linking to a folder? Am I misusing a method or am I not using the correct approach?

• Welcome to TeX - LaTeX! Please post the code you have tried. Loading hyperref and using \url should work, but will display the path name in the file too. What end result do you want? – Andrew Swann Jun 6 '18 at 8:59
• If you give a pathname to MS internet explorer, it will display the directory, but this is not standard behavior. The first thing it should do is look for home.html or index.html. Firefox defaults to using the search engine. – John Kormylo Jun 7 '18 at 15:08

For local paths:

\href{file:C:/foo/bar/baz/.}


The trailing period looks like a file extension so hyperref doesn't try to be smart and append ".pdf".

For UNC paths you need to double the leading forward-slashes for some reason:

\href{file:////server/share/foo/bar/baz/.}


There's no need to slash-escape embedded space characters in the path.

I haven't been able to get the usually-recommended \href{run:.......} syntax working for directories.

Tested on MikTeX (via Sweave) in Windows 10.

On MacOS, the MWE below produces:

and upon clicking on the link it invokes Finder and opens to the ../images directory.

## Notes:

• Only relative links work. Absolute directory paths do not seem to work.

## Code:

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\href{run:../images}{My Images Folder}
\end{document}


If it's a network folder, you can give the absolute path with

\href{run:/serverpath}


or

\href{run:///serverpath}


For example

\href{run:///192.198.1.5/data}{Network Folder}


If it's a local folder, you can give the absolute path with

\href{run://FolderPathOnC:Drive}


For example

\href{run://Users/Name/Downloads}{My Downloads Folder}


Tested with Adobe Acrobat Pro DC Version 2020.009.20065.

This is not a solution, but it does show some of my experiments.

\documentclass{article}
\usepackage[obeyspaces]{url}
\usepackage{hyperref}

\begin{document}
\url{C:/Program Files (x86)/7-Zip}% replace \ with /

\href{../slides/demo}{pdf}% relative pathname

\href{../slides}{directory}% does nothing

\href{../slides/}{directory}% does nothing
\end{document}