Windows 7 Symbolic Link - Cannot create a file when that file already exists

user1513171 picture user1513171 · Aug 20, 2012 · Viewed 73.5k times · Source

I'm trying to create a symbolic link between two directories. I have a directory called TestDocs and TestDocs2. I will be doing all my work in TestDocs, but I need it all to be reflected in TestDocs2. So all files that are in TestDocs2 will be replicated in TestDocs, and if I add a file, change a file, etc in TestDocs it should be reflected in TestDocs2.

So I thought it would be as simple as just doing this:

mklink /D TestDocs TestDocs2

But when I do that I get the error:

Cannot create a file when that file already exists

Why am I getting this?

Also, do I have the order of my TestDocs and TestDocs2 wrong in the command?

Thanks for the help, Symbolic Links have always confused me!

Answer

Jay picture Jay · Aug 20, 2012

The correct usage is:

MKLINK [options] {link} {target}

You're creating a link, so the link is the new link you're about to create.
And the target is the link's target, which is the existing directory.