Create symbolic links to directories in Windows

Symbolic links with “mklink” in Windows.

Recently I had the problem that I wanted to keep two “folders” in one application synchronised. So not synchronised in the sense of copying files, but one folder from each of two projects should always have the same content.

Symbolic links to directories in Windows

Symbolic links can be used to point one directory to another. The display is transparent during use, i.e. it looks like a normal directory to users and programmes.

Here is an example:

mklink /D "c:\targetfolder" "c:\sourcefolder"

The parameter “/D” creates a directory link from “sourcefolder” to “targetfolder”. The entry is made in the command prompt, whereby admin rights are required here.

In Explorer, the target directory is symbolised with a small link arrow. If we look inside the folder, we see the same files. Changes to one folder lead to a change in the other folder. However, this is not entirely correct, as the files and folders only exist once.

Remove symbolic links

We can also remove a link again using the “rd” command:

rd source

Leave a Reply

Your email address will not be published. Required fields are marked *