Using Symlinks in Windows for Fun and Profit
You may have heard of symlinks, or symbolic links, before, but weren't quite sure what they're good for. Symlinks are kind of like a wormhole in your filesystem--they're placeholders on the drive that redirect applications to whatever folder or file you point them at. They're especially handy when an application, like iTunes, doesn't allow you to configure the location it expects to find your music. So, instead of moving all your music to the folder that iTunes wants, you can simply create a symlink from the folder that iTunes expects to the folder that you prefer to store your music in. To your programs, a symlink is indistinguishable from the actual files in question.
We've found that symlinks are incredibly useful, and use them all the time. However, you can get into trouble using symlinks if you aren't careful. It's even possible to permanently damage your filesystem. The symlink is a powerful tool, and should be used carefully. When you're ready to learn, click to the next page.
  
Symlinks work best in Windows Vista and Windows 7 (OSX also includes symlinks, but we'll talk about them later). While they're lightly supported in Windows XP, they aren't quite as transparent to apps as in the later OSes, and we haven't tested them in XP, so your mileage may vary.

To create a symlink, open your command prompt--the quickest way is to press the Windows key and type cmd at the prompt--and browse to the folder you want to create a symlink in using  basic DOS commands. Once you're there, you'll use the mklink command to create your link. The basic structure of the command is mklink <arguments> <symlink> <targetoflink>. I'll break that down for you.

There are several arguments that mklink can take, but you'll probably only use two. The most useful command is the /j option, which lets you make a symlink to a directory. This will make the linked directory appear in a second location on your hard drive. You may also create a hard link to an individual file, rather than a directory by using the /h argument. The third option, /d, creates a soft link, which is more akin to a shortcut. The difference between the soft link and the hard link is that the file you hard link to appears to be stored in the link's location on the drive, while the soft linked file appears to be in its original location. If you want to symlink a directory, you must use the /j option.

In place of <symlink>, you'll need to enter the name you want for your symlink. If you're symlinking a directory, it's important that there not be a directory or file with the same name. So, if you're replacing a folder that already exists, you'll need to copy it someplace else before you can create the symlink. 

The <targetoflink> is the folder or file that you want to create the link to. You need to use the complete path to the file here, so if any of the folder names have spaces, you'll want to enclose the entire path in quotation marks.
Here are some examples:

mklink /j "c:\users\Will\Music\iTunes\iTunes Music" d:\Music\ - This line makes a symlink that redirects from the folder c:\users\Will\Music\iTunes\iTunes Music to the Music folder on my second hard drive. This type of use is especially handy if you have a small main hard drive and a larger secondary drive.

mklink /h "c:\users\Will\AppData\Roaming\AppName\settings.xml" "c:\users\Will\Dropbox\settings.xml" - This line builds a symlink between a specific settings file in your user profile directory and the same file in your Dropbox (Make sure you copy the file to your Dropbox first, or it will be overwritten!). You can use this to sync your settings across multiple computers.    
 
To delete a symlink, just browse to its location in Explorer, right click it, and press delete.
 

Beware: Danger Ahead 

There are a few things you shouldn't do, because they'll wreak havoc on your file system. There are two main rules. Don't create symlinks inside symlinks and don't create symlinks to symlinks. Doing either of these things can create loops inside the filesystem, which causes real problems for things like virus scanners.
27 Comments
Htorne on March 17, 2010
My God you guys are spamming content \o/ Yeaaa keep it up :)
Sandor on March 17, 2010
Nice stream of content guys. I dare not try this at the present time, maybe later if I can muster the courage :)
warmonked on March 17, 2010
dude, I wasn't even aware sym links were possible in windows o_O. I thought it was just a linux thing.
Technicolour on March 17, 2010
So what's the difference between /j and just using soft links for directories?
ALTF4_FOR_COLORS on March 17, 2010
Beware of solar flares when creating symlinks .
salvodelli on March 17, 2010
If you launch iTunes with the shift key held down, you can choose or create an iTunes library file in any location.  By default, iTunes will store its media in a folder next to the iTunes Library.itl file.  I use this technique to switch between different libraries (e.g. one that hold my lossless music ripped from CD and one that holds my day-to-day AAC encoded music that I sync to my iPod). 
 
I'm not saying that symlinks aren't useful, I just wanted to point out that for iTunes there are other ways to do this.
cohenjor on March 17, 2010


One of the most useful applications of hard directory junctions is actually with Steam.  Steam, despite how useful and awesome it is, still doesn't allow configuration for where your games download to.  Instead, they all go right into the Steam directory on whatever drive you installed Steam to. 
 
Now that I use an SSD, I want some slower-loading games on my SSD, and others to remain on my mechanical disk.  Symlinks allow me to do that. 
 
 
Scenario: 
1) Steam installed on my G drive at g:\games\steam 
2) SSD is my C drive, with a games folder at c:\games 
3) Battlefield: Bad Company 2 downloaded via Steam 
4) Copy-paste the *entire* directory G:\games\Steam\steamapps\common\battlefield bad company 2    to C:\games\ 
5) Open up command prompt, run this exact command: 
 
mklink /j "G:\games\Steam\steamapps\common\battlefield bad company 2 " "c:\games\battlefield bad company 2"

norman online on March 17, 2010
@ALTF4_FOR_COLORS:  my god, you've just invented time travel.
ALTF4_FOR_COLORS on March 17, 2010
@norman: 
1969 HERE I COME!!!
snide on March 17, 2010
@cohenjor: You are my new hero. You have no idea how much trouble I've had with STEAM being on my default C drive.
will on March 17, 2010
@Technicolour: You must use /j for a directory symlink. I've updated the article to be more clear. Thanks :)
Technicolour on March 17, 2010
@will: 
Oh that was a question because I have been using /D for my directories as was wondering what the difference is
LordAndrew on March 17, 2010

There are a few things you shouldn't do, because they'll wreak havoc on your file system. There are two main rules. Don't create symlinks inside symlinks and don't create symlinks to symlinks. Doing either of these things can create loops inside the filesystem, which causes real problems for things like virus scanners.

Reminds me of the time I mounted my C: drive in a directory on my C: drive. Which was totally worth it, by the way.
will on March 17, 2010
@LordAndrew: I made a symlink to my dropbox folder inside my dropbox once. The sync program thought that the folder was infinitely deep, and bad things happened, as a result.
Sandor on March 18, 2010
@will:  Now you're just playing with people's lives.
wonko33 on March 18, 2010
Is there a command to see what symlinks you currently have? I there a command to remove a symlink?
fish_face_mcgee on March 18, 2010
And favorite'd.  Great article guys, I'm definitely going to take advantage of this when I reinstall Win7 and reactivate my RAID.
will on March 18, 2010
@wonko33: You can just delete them like normal files in Windows Explorer. I've updated the article with that info.  Not sure about applications that show you all of them.
DieRunning on March 18, 2010
You've been Lifehacked. Congrats guys!
guggenhe on March 18, 2010

How's this different from creating a Window's Shortcut to a folder?
  • Type the words above including the space. Get new words?
Errors will go here
Post Reply
Processing....
Popular News
How To Rip DVDs to Play on Any Device—For Free!

Our ultimate DVD copying guide shows you how to use Handbrake to rip discs for playback on your laptop, Xbox, PS3, iPhone, Zune, netbook, iPad, PSP, iPod, and pretty much anything else

Video: How To Build the Best $1500 Gaming PC, Step-by-Step

Do you like saving money? What about playing PC games? Have you ever considered building your own PC? We show you exactly what you need to know to build an awesome $1500 gaming PC.

How To Build an Awesome $500 Windows Home Server

We pick the best parts to build a lean media backup and streaming machine.

Apple iPad Wi-Fi Review

Apple's device isn't magical, but it is going to make the tablet a real category--for better or for worse

Nexus One vs HTC Desire vs HTC Incredible: What's the Difference?

HTC is releasing more Android phones all the time, but is there a difference?

How To Steal Mac OS's Best Features for Windows

Windows 7's Aero is a fine UI, but there are just a few things it's missing. Here's how to steal some of Mac OS's features.

How To Rip a Blu-Ray Movie with Just One Click

The MakeMKV utility decrypts and rips a Blu-Ray disc with just one click, preserving the original video quality of the source file.

How To Stream All of Your Video Files to iPhone and iPad

Get your DVD rips off your computer and play them on a mobile device, without having to convert them beforehand.

The Comic-Con 2010 Cosplay Gallery: 850 Amazing Costumes

There is no bigger or better cosplay gallery on the internet.

Crapware on Android: Minor Annoyance or Major Problem?

Your new phone is probably stuffed full of junk, and you can't get rid of it.

How to Turn Your Panoramas Into Photographic Planets

It's incredibly simple to turn your photos into something straight out of Super Mario Galaxy — and the results look totally awesome too.

Intel Hits 50 Gb/s Optical Data Transfer Breakthrough

Intel has built a prototype silicon photonic link that uses both silicon circuits and optical connections to reach a transfer rate of 50 gigabits per second.

Apple Launches Magic Trackpad, On Sale Now for $69

The rumors were true.

Apple Updates iMac, Mac Pro and Cinema Display Lines

Apple's most notable announcement today might be its new Magic Touch trackpad peripheral, but the company also revealed several updates across its full range of desktop computer products.

Amazon Updates Kindle with $139 Wi-Fi, $189 3G Models

Amazon has announced two new versions of its Kindle e-book reader.

Android Market Roundup: Who Says Android Can't Game?

We'll show some of the hottest games available on Android right now, along with our take on them.

Free Friday - Win an Android Mini Vinyl Figurine!

This week we're giving away an awesome Android Mini figurine. All you need to do to enter is sign up for the site and post a comment in this thread. Yay!

The Comic-Con 2010 Cosplay Gallery: 850 Amazing Costumes

There is no bigger or better cosplay gallery on the internet.

Amazon Updates Kindle with $139 Wi-Fi, $189 3G Models

Amazon has announced two new versions of its Kindle e-book reader.

Apple Launches Magic Trackpad, On Sale Now for $69

The rumors were true.

How to Turn Your Panoramas Into Photographic Planets

It's incredibly simple to turn your photos into something straight out of Super Mario Galaxy — and the results look totally awesome too.

Crapware on Android: Minor Annoyance or Major Problem?

Your new phone is probably stuffed full of junk, and you can't get rid of it.

Intel Hits 50 Gb/s Optical Data Transfer Breakthrough

Intel has built a prototype silicon photonic link that uses both silicon circuits and optical connections to reach a transfer rate of 50 gigabits per second.

JPEG And You: How The Most Popular Photo Format Works

Why Jpeg is still the go-to format for photographers and the internet at large.