Creating links to folders and files in Windows helps with the management and organisation of your files. In Windows, links to folders and files are known as symbolic links, they allow you to access files on the PC using an alias file name, folder name or path. For example, if a file you update frequently exists in "C:\Windows\System32\drivers\etc", a symbolic link can be made to for the folder named "C:\my-etc" which will save a lot of typing.
Symbolic links can be created in Windows using the mklink command in the CMD command line interface. To ensure that permissions are sufficient CMD needs to be run as an administrator as follows...
- Type cmd into the task bar search box
- Right click on the Command Prompt icon and select Run as Administrator
- Click Yes in the User Account Control window
The options for the mklink command are:
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link Specifies the new symbolic link name.
Target Specifies the path (relative or absolute) that the new link refers to.
Some advantages and examples of using symbolic links are:
- Shortening long paths to make it easier to navigate to files. e.g. mklink /d C:\Windows\System32\drivers\etc C:\my-etc
- Avoiding the need to use folder / file names containing spaces such as "C:\Program Files". Some programs require that folders containing spaces are wrapped in quotes for them to run correctly.
- Easy to remember names can be used to access files instead of weird original folder and file names while leaving the original untouched.
- If files are shared across computers on a network which have different file structures, symbolic links can be used to standardise references to files no matter where they are stored on each PC. For example, if a program on your PC uses an image file located on a cloud location mapped to D:\media\images but on your laptop the same program accesses the same image file via C:\media\images the file will need to be duplicated in order to allow the program to find the file. To get around this a symbolic link can be made on the PC as follows... mklink /d "D:\media\images" "C:\media\images" This way, the programme whether it is run from the PC or the laptop will only ever have to point to the file at C:\media\images