Directory Linking

I’ve set up symbolic linking in windows as I wanted automatic backup of data to Dropbox and I don’t want to keep copying the folders with changed items into by Dropbox folder. ┬áThis is easy to do in Linux but not so easy under windows. By linking these folders to a folder in my Dropbox I get them backed up without any hassle.┬áTo do this I used the mklink command that is part of the windows operating system on Vista machines upwards. If you are using symbolic links it works across drives although the drawback to symbolic links is sometimes some programs won’t work properly with them. I had a program today that kept telling me the file was in use it wasn’t but copying it into a regular folder allowed it work. However the Dropbox client worked fine.

To do this I opened the command prompt and used the following syntax for the command:

mklink /D <new link name> <source directory>

e.g.

mkdir /D C:\VideoFiles D:\Dropbox\Videos

the screen then shows below that

symbolic link created for D:\Dropbox\Videos <<===>> C:\VideoFiles

The parameters available for mklink are:

/h to create a hard link

This can only link to files on the same drive. You must specify the full pathname it cannot be relative to your current position

/j creates a directory junction

This can only link to directories and creates a hardlink to the directory. You must specify the full pathname it cannot be relative to your current position.

/d creates a directory symbolic link

This can only link to directories and creates a symbolic link that can span across drives. The pathname can be a relative reference provided it is on the same drive.

mklink

without a parameter will create a file symbolic link

Leave a Reply

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