brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mklink /J makes a folder show up in a second place

Terminal
~/tips/tip-windows-mklink-junction

mklink /J "C:\Games\SaveData" "D:\Storage\SaveData"

Creates a directory junction so a folder appears under a second path.

Some programs insist on a fixed folder, and the drive it lives on is full. A link lets the folder stay where the space is while the program still finds it where it expects.

mklink creates links in a Command Prompt. The syntax from the docs is mklink [[/d] | [/h] | [/j]] <link> <target>. By default it creates a file symbolic link. With /d you get a directory symbolic link, with /h a hard link, and with /j a directory junction.

mklink /J "C:\Games\SaveData" "D:\Storage\SaveData"

Note the order: first the link, which is the new name, then the target, the real folder that it points to. After the command, opening C:\Games\SaveData shows the contents of D:\Storage\SaveData.

I would move the data first and create the link second: with the program closed, move the original folder to the other drive, then run mklink /J with the old path as the link name. The link name is a new name, so the old folder must not be sitting at that path any more.

The directory symbolic link is the same idea with a different type:

mklink /D C:\Tools D:\Tools

Which one should you use? The docs only name the types; they do not tell you which is better for which case. A directory symbolic link is the one the docs show in their own example, together with a hard link for a single file. For a plain “this folder also lives over there” case I would start with the junction.

The caveat is about removing links. The docs example removes a directory link with rd and a file link with del. Use those on the link itself, and do not run a recursive delete on it before you have tested on a throwaway folder, because I did not check how every tool treats the target behind a link. Also remember that backup and sync tools may follow a link and copy the target, or may skip it, so check what yours does.

Further reading: mklink

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link