A symlink is an acronym for a symbolic link. It is a shortcut to a targeted file/folder.
Here is how it works.
I was working on a project for which I have to work both at home and in office. One was a MacBook with MAMP and the other was a PC with XAMPP installed. So the files are in MAMP and XAMPP. With the help of symlink, I kept the files in my Dropbox although it seems if it’s in both MAMP and XAMPP. Meaning that all the files are synced through Dropbox. Thank God 🙂
Here’s how to do that on Windows.
Create a symlink to a file:
mklink Link Target
/D when you want to create a soft link pointing to a directory. like so:
mklink /D Link Target
/H when you want to create a hard link pointing to a file:
mklink /H Link Target
/J to create a hard link pointing to a directory, also known as a directory junction:
mklink /J Link Target
So, for example, if you wanted to create a hard link at
C:\LinkToFolder that pointed to
C:\Users\Name\OriginalFolder, you’d run the following command:
mklink /J C:\LinkToFolder C:\Users\Name\OriginalFolder
You’ll need to put quotation marks around paths with spaces. For example, if the folders are instead named
C:\Link To Folder and
C:\Users\Name\Original Folder, you’d use the following command instead:
mklink /J "C:\Link To Folder" "C:\Users\Name\Original Folder"