How to make a soft link for a folder or file

How to make a soft link for a folder or file

Sometimes, you installed a piece of software to drive C but you want to change the path of the installing folder of this piece of software to save the space of drive C. Sometimes, the user data folder of a browser is set to be located in drive C and you want to make the folder to be located in another disk. Sometimes, a file is generated in a drive C and you want it to be generated in drive D. This is when you need to make a soft link for a file or folder. Without the further ado, let's see how to do it in the upcoming parts of this article.

How to make a soft link for a file

To make a soft link for a file, you will need to use the command "mklink".

  • First, copy and paste the file in the source directory to the directory you want to move and delete the file in the source directory. Please note deleting the file in the source directory is necessary. If the file in the source directory does not store any important data you want, you don't need to copy and paste it.
  • Press the "Win+R" keys from your keyboard. Type "CMD" and click on "OK" to open the Command Prompt window.
  • Type mklink "the path of the source directory" "the path of the target directory" and press the "Enter" key. There is a space between two paths and a space between mklink and "the path of the source directory". Don't forget to type quotes for two paths. The two paths should be the absolute path because you want to create a soft link crossing local drives.

Let's say, you want to make a soft link for the "History" file of chrome to move its directory from drive C to drive D.

  • Copy the "History" file to the new directory and delete the "History" file in drive C.
  • Open the CMD window.
  • Type mklink "C:\Users\username\AppData\Local\Google\User Data\Default\History" "D:\Program Files\Google Chrome\History"
  • Press the "Enter" key. You will see the prompt that the soft link is created successfully.
  • Right-click on the "History" file in drive C and you will be navigated to the "Shortcut" tab. This means the current "History" file in drive C works as a shortcut, which is the created soft link and directs the file to a new location.

How to make a soft link for a folder

To make a soft link for a folder, you need to use the command "mklink /d".

  • First, copy and paste the folder in the source directory to a new directory and delete the folder in the source directory. Please note deleting the folder in the source directory is necessary. If the original folder does not store anything you need, you don't need to copy and paste it.
  • Press the "Win+R" keys from your keyboard. Type "CMD" and click on "OK" to open the Command Prompt window.
  • Type mklink /d "the path of the source directory" "the path of the target directory" and press the "Enter" key. There is a space between two paths and a space between mklink and "the path of the source directory". Don't forget to type quotes for two paths. The two paths should be the absolute path because you want to create a soft link crossing local drives.

Let's say, you want to make a soft link for the "CacheStorage" folder of chrome to move its directory from drive C to drive D.

  • Delete the "CacheStorage" folder in drive C. Open the CMD window.
  • Type mklink /d "C:\Users\username\AppData\Local\Google\User Data\Default\Service Worker\CacheStorage" "D:\Program Files\Google Chrome\CacheStorage"
  • Press the "Enter" key. You will see the prompt that the soft link is created successfully.
  • Right-click on the "CacheStorage" folder in drive C and you will be navigated to the "Shortcut" tab. This means the current "CacheStorage" folder in drive C works as a shortcut, which is the created soft link and directs the folder to a new location.

Conclusion

Creating a soft link is a good way to move folders or files of the software from across drives to save the space of drive C. When the software visits the soft link, it actually visits the folder the soft link points to. If you like this article and think it is very useful, share it with your friends.

Recommended Reading

How to remove the "DocumentAncestors" metadata

How to solve "Windows Photo Viewer can't display this picture"

How to fix event ID 10016 error

Avatar for Dong Liu
Dong Liu

Software tech makes life more convenient and helps people manage work in a more efficient way. As a tech geek, I select practical gadgets and share you with them. Should you have any advice, please feel free to let me know.

Leave a comment

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