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

Viewed 78016

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!

5 Answers

I had the same issue. You have to make sure the Source folder does not already exist. (if it does , then rename it to something else)

In case of below Backup folder should not exist under MobileSync. Since Apple iTunes looks for Backup folder with that name, just rename the existing folder to something like OriginalBackup to avoid iTunes from finding it. Instead the mklink will synonym Backup to D: folder as below

mklink /J C:\Users\Dell\Apple\MobileSync\Backup D:\Apple\Backup\iPhoneXRBackup

I had this error. Two things I did to fix it.

  1. check I was actually in the directory I thought I was and not another one with a very similar path.
  2. put quotes around the new link name.

First attempt: mklink /d \shared_files ....\my-app-public\src\shared_files gave error described.

Second attempt: mklink /d “.\shared_files” ....\my-app-public\src\shared_files worked fine.

Related