Monday, June 1

Creating symbolic/Symlink in windows 7

How to create Symbolic Links in Windows 7

But before that, what are symbolic links? I had no clue what symbolic links were until I actually I had to use them. I got to learn about it through a colleague and later with some research was able to create my own sym links.

Where I used Symbolic Links?
Was working on this java project which was located in a particular directory. I was using Sublime text 3 as my editor, however due to some reason the less compiler did not work as expected. In my defense, I did spend considerable amount of time trying to fix the issue, however then realized that it was a waste of time and so installed Netbeans IDE for PHP. It uses the lessc from nodejs to compile less files. After installing the IDE, I had to create a project, at first creating a project folder in the same source code directory would have helped, but it would create unnecessary netbeans related folder. That's when symbolic links came to rescue.

What are symbolic links?
Here's an awesome article from How to Geek which explains it very well.
So symbolic links or symlinks are advanced shortcuts. So if you create a symlink to a folder/file, it would be available on that location for edit etc. however the real location would be from where you created the symlink. So you have two paths for the same files/folders, however technically the physical locations is at just one path.

How to create symbolic links?
Lets say, your folder of choice is at location
However you want to address the folders and files from a different location say from your Documents and settings folder
C:\Users\ALPHA_ADMIN\Documents\Alpha Documents\netbeans_projectAlpha
 Let's Create a symlink
Go to your command prompt and type "mklink /?", it gives you all the helper functions available.

In our scenario, we need to create a Directory junction. So we will be using "/J" in our command.

The command would like this
mklink /J "target_path/folderName" "source_path_till_folder"

Note that, we are using quotes in the path, considering that there might be space in folder names. Also when you create a symlink in your target directory, you need to provide the folder name in addition to the target path to which you wish to create a symlink.

So the actual command would like this
mkink /J "C:\Users\ALPHA_ADMIN\Documents\Alpha Documents\netbeans_projectAlpha\projectAlpha" "C:\p4root\depot\mainFolder\projectAlpha"
 In above command, we have folder till "netbeans_projectAlpha", we have explicitly appended "projectAlpha" to the path so that the symlink is created for that folder.

After you create a symlink you get a "Junction created" message. And the folder has a shortcut icon to it.

Be the first one to Comment!!!

Post a Comment