There is a Windows feature that most people have never heard of before, but is extremely useful.
It's basically a way to create, you can think of it like "super shortcuts" to files and folders,
but what exactly does that mean and why is it so useful? That's what I'm gonna explain
and then show you how to make some yourself. The general term for what I'm talking about
are symbolic links or symlinks. And they're not exclusive to Windows, they are on other operating
systems. And there's a couple of different names that we'll be getting into but the general term
is symbolic links. And looking at them in Windows Explorer, it kind of looks the same with the same
icon as a regular shortcut. However, there are subtle, but big differences. If you, for example,
create a shortcut in Windows Explorer, and then click it to go to a new directory. You are
basically in that new directory. The path changed, it's kind of like teleporting, you can think of.
You teleported to the other location on the hard drive. With a symlink to a directory though,
you still go to that new directory and you still see all the files just like as if you
went to that other directory, the normal way. But notice the file path this time,
the upper levels of that file path are actually the same, they didn't change like it did with
a shortcut. And if you navigate into further directories, it still stays the same. So even
though you are actually accessing directories and files that are technically in another location,
any software that goes through the symlink will just see it as being part of the original path and
it's not like a shortcut that moved you. So it's thinking like, whereas a shortcut is a teleporter,
a symlink is like a portal. So in other words, what I mean by that is when you click a shortcut,
you're teleported, it's kind of like a one-off thing. You move directories and now anything you
do over there, stays over there or whatever. Whereas if you access it through a symlink,
the portal stays open while you're going in and doing whatever. So any time you modify the
directories or files within that symlink, you're actually modifying the real files that are located
somewhere else, but the software sees it as happening at this symlink directory, which
is not the technical actual place it is, but it still affects the other location. Symlinks
can also be used for individual files, not just a whole directory. So with a shortcut, if you create
a shortcut to a file, it'll open up that file, whereas with a symlink, it'll still open up that
file, but it'll look like that file is in the symlink directory and not the real place it is.
So the program thinks it's again, somewhere it's not. However, some smarter programs like Notepad++
might recognize it as a symlink and actually open and show the path of the real file. Now,
you might be wondering, "All right, it doesn't seem like that big of a difference. Why is this
such a big deal?" And let me give you some example use cases. Say, you're installing a program and it
doesn't let you choose where you want to install those files, but it's a big program or something,
and you wanna move it to a secondary drive, not your main drive, but you can't choose where to
install it. So what you could do is install the program and then move the files to whatever drive
you want, whatever location you want, and then create a symlink from the original location to
the new one. And then the program will just be happy to run the files through the symlink. It
doesn't know that they're on the other drive, it sees it as being the same exact directory location
as before. One really common use is for cloud storage services like Dropbox or OneDrive, where
they usually give you one folder to put all the stuff you want to be backed up and synced into,
but say you want to backup and sync files that are located elsewhere on your computer. And you don't
wanna just put it all into this one folder, you wanna keep the locations you have. What you could
do is create a symlink in the Dropbox or OneDrive folder that goes to whatever files you want that
are located anywhere and Dropbox or OneDrive will now think that those files are in that folder
and just kind of sync them to the cloud. So, effectively you can sync whatever you want, not
just what's in the one folder. Now, a third use case is one that I actually had to use recently
and it kind of inspired this video, which is, say, you move a directory with a whole bunch of files,
you were using for other stuff, and you move it to another drive. In my case, my Dropbox folder,
but a bunch of programs were using those files and they were referenced to that location. And now,
they're gonna think those files are all missing. You'd have to go in and individually tell the
program where these new files are. And while I did update the references in the programs, when I
could, I figured there would be some that I forgot about and I didn't really want to break anything.
So I simply created a symlink for the Dropbox folder, from the old location into the new one.
And then any programs that are now looking for those files will not even know that the Dropbox
moved at all. And of course, everything is still located through the actual path. So it's not,
like you have to use the symlink path from now on. It's like, you can use both. Now, there are some
other major differences between regular shortcuts that you're familiar with and symlinks. So let
me talk about those to make things a little bit more clear. First of all, a shortcut in Windows
is actually a file in itself and it actually has its own file extension .lnk or "dot link". This
file extension will not normally show even if you enable showing file extensions for other
file types. The only way to get it to show is to go into the registry. There is a registry tweak,
and then it'll make Windows show it. And also, it'll drive this home because it is file,
it has a size, even though it's kind of small. So Windows shortcuts are pretty much
just made to be used with Windows Explorer, and they might not necessarily be supported
by other third party programs unless the developer added that support in. Just like any other file
type if the program doesn't support that file type, then it won't work. For example, you can see
this program Dev C++ tries to open it and just the raw data shows up. So if you move a file and then
create a shortcut to the new location and rename the shortcut to the same file type as before,
thinking that, "Oh, now the program will see the shortcut, try to access it and then move
to the new location." No, that doesn't work. It's going to see the .lnk extension, say,
"This isn't the file I'm looking for, where's the file?" And then just mark it as missing. Symbolic
links though, are actual features built directly into the file system. So it's not like there's any
.lnk extension. The program will just access the symlink and it won't even know that it's
a symlink. It just gets automatically resolved to its new location and for what it knows, it's still
accessing the same path as before. It doesn't know that it's in some other path or some other driver
or whatever. Another difference is you usually can't execute a command on a shortcut. So if
you use CMD or something and try to do something with a shortcut, it's not gonna know to redirect
the command to the thing it's pointing to. If you do it with a symlink though, the command
actually will be redirected to act on the path of the actual location, that file, and it will
work fine. Before showing you how to create these different symlinks. There are a couple of terms,
you'll see that I need to explain. You don't have to remember the details here. Just know that they
exist, basically. So again, symbolic links are a general term. They're not exclusive to Windows,
they've actually been around for ages since like the '70s at least. So they're not new. However, in
Windows, there are three types of symbolic links. Now, the first type is simply called symbolic
link. That's the only slightly confusing thing. So, of the symbolic links types, one of them
is just called symbolic link. And this does all the same stuff that we just talked about. It can
redirect to files and folders, and it's actually the newest of the three types. And it's also
probably the most versatile. So this is the one most people are gonna use. However, there are two
other older types which are basically just kept around as a legacy thing for compatibility. One of
them is called a junction, AKA a soft link, which is basically just going to work for directories.
And then the other one is a hard link, which only works on files. But again, for the most part,
the symbolic link feature can do the job of both of these. So that's the one that most people
are gonna be using. Now, there are some minor differences. So I, at least, want to mention what
those are because technically the older legacy ones might still be useful in some certain limited
circumstances, which you'll see. So with a hard link, again, this can only be used for individual
files, not directories. And another limitation is hard links can only be used to redirect to files
on the same volume of a drive. So the same drive letter, basically. So it can't go to another drive
or another partition or anything else. Whereas a symbolic link can go to any path, even a remote
directory on another computer, like a mapped network drive or something. So that's a big win
for symbolic links. However, there is an advantage to hard links, which symbolic links cannot do,
which is if you move the target file, the hard link will actually get updated automatically. So
for example, you can see here, I have this text file in this "Test/Folder A" and it contains the
text, big chungus. And I've created a hard link to this file in the root directory of the drive. And
notice how it can be a different name. It doesn't have to be the same exact thing. And you'll notice
with a hard link, it looks like the actual file. There's no shortcut symbol or anything.
And that is one notable unique thing about hard links is that a hard link to an individual file
is basically indistinguishable from an actual file. If you like to go to properties, it's just
gonna look an actual file. You don't know that it's a hard link necessarily. And even if you
use the directory command in the command prompt, it will recognize symlinks and junctions, but
not hard links. So if you create a hard link, just make sure you don't forget which one is which, and
delete the wrong one by accident. Anyway, you can see that if I move the target file to Folder B,
the link actually still works. It gets updated. So just to make sure that's actually what's
happening, let's change the text in the file to say, "big chugus abc." And when we go and check
the link again, yup, it still goes to that updated text file. So it obviously updated the link, it's
in a new location now. So a hard link could be better if you're gonna be dealing with files that
are gonna be moved around and updated, but still will stay on the same exact volume. All right,
now, let's do junction. And again, this is a type of symbolic link that only works on a directory. A
limitation of junctions is the target directory must be on the same computer. It can be on
a different volume and drive, unlike a hard link, it just has to be on the same computer. So for
example, it can't be on a mapped network drive or remote location. Whereas again, symbolic links can
be anywhere even on a remote location. And also, junctions can't do relative paths, they have to
be an absolute path, whereas symbolic links can. So not really many advantages to junction, except
maybe for security purposes. You don't wanna create a junction that might go to another network
drive or something. But for the most part, there's not really any advantage to using one. All right,
so now you know how everything works. Let's get into how to actually make some of these symbolic
links. So what you'll do is open up the command prompt and we're gonna use the command "mklink",
which is short for make link. And if you don't type anything else in just hit Enter here, it'll
show you all the parameters for this command and basically how it works. The /H and /J parameters
there are for hard links and junctions, and we're just gonna ignore those, but it's basically the
same exact process and I already showed you how they work. Really, the only optional parameter
here is /D, which you need to put if it's going to be a symbolic link for a directory. Otherwise,
just the default is gonna be for a file. So say, I want to make a link to the Test folder on my C:
Drive. So that's the target and it's coming from the D: Drive. So first, you do mklink /D , Then
you need to put the path for where the link will exist, so a 'from' location. So let's call it
D:\examplelinktest. That's gonna be the fake link directory. And again, it doesn't need to
match the target, you just make whatever you want. And then you put a space and the target directory,
which is where we're going to, and it's just gonna be C:\Test . Now, it will say that the link was
created and show little arrows with the different paths. So we can test it, if we go into the D:
Drive and then go into the symbolic link, it now looks like the files are in the same
D:\examplelinktest path directory, but they're not. We know that they're actually in the
C:\Test and we can still access it from that real directory, but now also through the symbolic link.
And also, it doesn't take up any space on the D: Drive where the symbolic link is, it only takes up
space on the real location. Now, if you want to delete a symbolic link, you can delete it just
like a shortcut and it won't affect the directory that is pointing to. However, remember, that if
you go into the symbolic link and you're looking at the files that are in the other location,
modifying them and deleting the files that are in that other location will actually delete them.
So you can delete the entire symlink because it's just the link. But if you go in and delete
anything in modifying thing, you're actually modifying that stuff. All right, now, through a
file example. It's pretty much the same process. So let's just target a specific text file in
another folder, called hello.txt. So, first, let's decide where the link will be from, and let's do
D:\hellolinkexample.txt . It could be named anything, but just make sure you use the same
file extension, so it's gonna open up in the right program. Then we can get the path of the file to
target. And by the way, one easy way to do this is Shift + Right Click on the file and hit "Copy
as Path" that copies the path to the clipboard, whether it's a file or folder, it works on both,
and then you can just paste it into the command. And remember, since it's a file, we don't need
any other parameters, file is default. So we can just hit Enter and it'll say symbolic link created
again. And now, this file opens up and edits just like it would the original. And unlike a
hard link, it actually does show the shortcut symbol, but if you do right click it, you will
notice it says the type of file is a symlink txt file, not a shortcut. Oh, and one side thing,
if you're wondering what happens if you delete the .lnk extension off of a shortcut, I was wondering
the same thing. And it seems to depend on the program for this shortcut to a text file. I opened
it with Notepad++, and it still recognized it as a shortcut and opened the target text file. But
regular Notepad literally just opened up the raw data of the shortcut. But anyway, with all this
knowledge, you're now ready to go and use this incredibly useful feature, or maybe not right now,
but you'll come across some day where you're like, "Ah, I remember that." And you can take advantage
of it. If you found this video useful, be sure to give it a thumbs up and let me know down in
the comments if you knew about this before or not. And if you guys wanna subscribe, be sure to also
click the bell next to the Subscribe button. I make videos about twice a week, not too often. So
you don't wanna have them get lost in the rest of your subscription feed. Now, if you guys wanna
keep watching, the next video I recommend is why sometimes you plug in a USB drive, but it doesn't
show up in Windows, why is that? I explain how to fix it in a few different ways. So you can click
on that right there to watch it. So thanks for watching guys and I'll see you in the next one.