How to Create a Directory Junction in Windows

  A Directory Junction (also known as a Junction Point) lets you access a directory’s contents from another location. To put it more clearly, let’s say you have a directory – “D:\Projects\Current Projects”. Now, you want the contents of this directory to be available simultaneously at another location – “E:\Data\Pending Projects”. You don’t want to have two copies of every file because it would waste valuable disk space. What would you do? How would you access these files from both locations while storing them at only one place? We’ll show you how. Here, we’ll tell you how to create a Directory Junction in Windows using mklink.

How to Create a Directory Junction in Windows?

  A Directory Junction is actually a kind of shortcut or link. As a Windows user, you’re already aware of shortcuts. You click on a shortcut (which is actually a file) and the destination file or folder opens.

  However, a Directory Junction is quite different from a normal shortcut. It looks and works like a normal directory. You click on a directory junction and its contents (that are actually stored somewhere else) are displayed as if they’re really located inside that directory. You can even edit/delete those files and folders and the changes will occur at the original location instantly. To understand it more clearly, have a look at the images below :

Actual Location of Files

Actual Location of Files

The same files are accessible from the Directory Junction

The same files are accessible from the Directory Junction

  As you can in the above images, the files are located only at “D:\Projects\Current Projects” but appear to be present at “E:\Data\Pending Projects” as well. Here, the second image shows how the Directory Junction appears. Have a look at the address bar in both images and you’ll appreciate how COOL it is.

How does it work?

  As you’ve seen above, “D:\Projects\Current Projects” is an existing location that contains some files. Now, we create a link to it (which we call a directory junction). We use the mklink command in the Command Prompt. The syntax of mklink is :

MKLINK [[/D] | [/H] | [/J]] Link Target

The mklink command creates several types of links apart from Directory Junctions. We’ll not cover those links. Here, we need to create a Directory Junction. Therefore, our syntax would be :

MKLINK /J Link Target

Here, Target represents the existing directory that actually contains the data, while Link is the directory that we’re going to create. In our case, “D:\Projects\Current Projects” is the Target while “E:\Data\Pending Projects” is the Link. Please Note that there should not be an existing directory named “Pending Projects” in “E:\Data\”, otherwise the command will show an error and the Directory Junction will not be created. Now, we execute the following command :

mklink /j “E:\Data\Pending Projects” “D:\Projects\Current Projects”

The result is :

How to Create a Directory Junction - Directory Junction Created

How to Create a Directory Junction – Directory Junction Created

  The Directory Junction looks like this :

The Directory Junction looks like a shortcut but works like a folder

The Directory Junction looks like a shortcut but works like a folder

Create a Directory Junction

  If your computer has lots of redundant files (i.e. files which have been stored at multiple locations), you must use Directory Junctions. Apart from freeing up some disk space, you can also keep track of your files in a better way. If you like this article, SHARE IT. If you have any queries, let us know.

(Visited 561 times, 2 visits today)

One comment

  • Wonderful! Accessing a file from two different folders is a really cool thing. I have used it on some of my folders and it works great. 🙂 Thanks

Leave a Reply

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