Useful command-line: MKLINK (NTFS symbolic links)

Y

Yousuf Khan

NTFS symbolic link - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/NTFS_symbolic_link

For those of you familiar with Unix/Linux this is exactly the same thing
as the "ln" command in those operating systems, which creates hard and
soft symbolic links. Mklink is POSIX-compliant too.

For those you not familiar with that Unix command, then you can consider
this to be an aliasing command for files and folders. It lets you create
an alias name for any files or folders without actually having to make a
new copy of those files or folders. This is different than the familiar
Windows shortcuts, as shortcuts are not transparent to applications.
This means that you can access a file inside an application with its
original name, or its alias name, and the program will not be aware of a
difference. If you tried this with the old Shortcuts, the program would
need to know that it's a shortcut, and then it would need to read inside
the shortcut to find the original file. A symbolic link on the other
hand is just another entry in the file system for the same file.

This command is only available in Vista and Win7, it wasn't available in
XP. There might be a separate command available in XP though.

There is also a GUI available for this, if you don't want to mess with
the command line, called symlinker. It's just a frontend for the mklink
command.

symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
symlink utility - Google Project Hosting
http://code.google.com/p/symlinker/

Yousuf Khan
 
G

Gene E. Bloch

NTFS symbolic link - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/NTFS_symbolic_link

For those of you familiar with Unix/Linux this is exactly the same thing
as the "ln" command in those operating systems, which creates hard and
soft symbolic links. Mklink is POSIX-compliant too.

For those you not familiar with that Unix command, then you can consider
this to be an aliasing command for files and folders. It lets you create
an alias name for any files or folders without actually having to make a
new copy of those files or folders. This is different than the familiar
Windows shortcuts, as shortcuts are not transparent to applications.
This means that you can access a file inside an application with its
original name, or its alias name, and the program will not be aware of a
difference. If you tried this with the old Shortcuts, the program would
need to know that it's a shortcut, and then it would need to read inside
the shortcut to find the original file. A symbolic link on the other
hand is just another entry in the file system for the same file.

This command is only available in Vista and Win7, it wasn't available in
XP. There might be a separate command available in XP though.

There is also a GUI available for this, if you don't want to mess with
the command line, called symlinker. It's just a frontend for the mklink
command.

symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
symlink utility - Google Project Hosting
http://code.google.com/p/symlinker/

Yousuf Khan
Thanks. It seems worth at least a look, so I grabbed the link.
 
Y

Yousuf Khan

Thanks. It seems worth at least a look, so I grabbed the link.
I discovered the symbolic link feature of Windows as I was trying out a
new duplicate file finder program called Duplicate Cleaner. One of its
cleanup options beyond just deleting duplicates is an ability to replace
duplicates with symbolic links instead. This way you can keep all of the
filenames in their original places, but not have them taking up any
additional space on your disk, since all of the filenames point back to
just a single actual file.

Prior to this, I was grumbling about why Windows doesn't have anything
as useful as the Unix symbolic links. Of course, the old Windows
shortcuts were crappy imitations of symbolic links. The Windows "mklink"
command even preserves the feel of the Unix "ln" (link) command. Not
that it matters to anyone not familiar with Unix, but this is
Microsoft's attempt at making Windows POSIX-compliant, so they did a
fairly good job at it.

Yousuf Khan
 
G

Gene E. Bloch

Put it back when you're done. Someone else may want to use it.
Good point. I'll try to get to it quickly so I don't keep it too long.

Thanks for the moral guidance.
 
G

Gene E. Bloch

I discovered the symbolic link feature of Windows as I was trying out a
new duplicate file finder program called Duplicate Cleaner. One of its
cleanup options beyond just deleting duplicates is an ability to replace
duplicates with symbolic links instead. This way you can keep all of the
filenames in their original places, but not have them taking up any
additional space on your disk, since all of the filenames point back to
just a single actual file.

Prior to this, I was grumbling about why Windows doesn't have anything
as useful as the Unix symbolic links. Of course, the old Windows
shortcuts were crappy imitations of symbolic links. The Windows "mklink"
command even preserves the feel of the Unix "ln" (link) command. Not
that it matters to anyone not familiar with Unix, but this is
Microsoft's attempt at making Windows POSIX-compliant, so they did a
fairly good job at it.

Yousuf Khan
I will assume (read: hope) that Windows does the right thing when links
are deleted, i.e., not put the link into the recycle bin, and of course
delete the underlying file if and only if the last symbolic link goes
away.

And it's easy to test the above.

And I have to go look at the site now - I promised Char.
 
G

Gene E. Bloch

I will assume (read: hope) that Windows does the right thing when links
are deleted, i.e., not put the link into the recycle bin, and of course
delete the underlying file if and only if the last symbolic link goes
away.

And it's easy to test the above.

And I have to go look at the site now - I promised Char.
Fils in tow ways...

One is that the links do go to the recycle bin on deletion - but that is
just my opinion as to what is right, and really shouldn't count.

The other is more serious and is *not* Unix-like[1]. True enough, if you
delete the existing symbolic links, the file itself is not deleted. But
if you delete the file, the symbolic links point to nothing.

[1] Or maybe in the dozen years since I did anything Unix, I forgot the
distinctions between the different link types. So I'll do another
experiment before clicking on Send...

This is better. This time I made *hard* links and deleted the original
file, but the links I made still pointed to the right contents. I
couldn't really test whether the file still existed after I deleted both
hard links (sort of like Captain Kirk floating outside the Enterprise
after a transporter malfunction), because I don't know, and am too lazy
to find out at the moment, how to browse the file system appropriately.

Delete still uses the recycle bin, however, but as I said...
 
C

Char Jackson

I will assume (read: hope) that Windows does the right thing when links
are deleted, i.e., not put the link into the recycle bin, and of course
delete the underlying file if and only if the last symbolic link goes
away.

And it's easy to test the above.

And I have to go look at the site now - I promised Char.
:)
 
Y

Yousuf Khan

Fils in tow ways...

One is that the links do go to the recycle bin on deletion - but that is
just my opinion as to what is right, and really shouldn't count.

The other is more serious and is *not* Unix-like[1]. True enough, if you
delete the existing symbolic links, the file itself is not deleted. But
if you delete the file, the symbolic links point to nothing.
I'll just point out some terminology that I use so there's no confusion,
I know terminology is a little ambiguous sometimes. I use the term
"symbolic link" as a generic term for both types of links, and I use the
terms "hard link" and "soft link" more specifically. I know often some
people equate "symbolic link" to "soft link", but I don't.
[1] Or maybe in the dozen years since I did anything Unix, I forgot the
distinctions between the different link types. So I'll do another
experiment before clicking on Send...
That'll happen in Unix too, when you're using soft links rather than
hard links. The main advantage to soft links over hard links is that you
can use them to point to files in other file systems, even over network
file systems. The main disadvantage is as you said, that if the original
file goes missing, then soft links remain as orphans. Hard links can
never be orphaned, as each link is just as legitimate a pointer to file
as all of the other links, but they can't cross file system boundaries.
This is better. This time I made *hard* links and deleted the original
file, but the links I made still pointed to the right contents. I
couldn't really test whether the file still existed after I deleted both
hard links (sort of like Captain Kirk floating outside the Enterprise
after a transporter malfunction), because I don't know, and am too lazy
to find out at the moment, how to browse the file system appropriately.
In computerese, hard links maintain coherency, but soft links don't. But
you give up flexibility with hard links.

Yousuf Khan
 
G

Gene E. Bloch

And I did it.

Thus my experiments & the interesting interchange with Yousuf Khan.

I also learned that if I were to start working in *nix again, I'd need
to learn stuff - probably *lots* of stuff. Like I must have once known
the difference between hard and soft links, whereas yesterday I only
remembered that there was a distinction to learn about. I don't think I
even remember the commands in vi, which I once spoke almost as well as
English :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top