58

I am trying to create a symbolic link on my win7 64bit machine to redirect the iTunes backup data to another drive. I am pretty sure the syntax is correct but cannot understand how to clear this error. I have tried both commands below which have the same error. I am running in Administrator Command Window. Could there be some corporate group policy preventing me from running this command?

mklink /D "C:\Users\odellt1\AppData\Roaming\Apple Computer\MobileSync\Backup" "E:\Apple Computer\MobileSync\Backup" 

or

mklink /J "C:\Users\odellt1\AppData\Roaming\Apple Computer\MobileSync\Backup" "E:\Apple Computer\MobileSync\Backup"

Error

Cannot create a file when that file already exists.

ChiliYago
  • 5,415

5 Answers5

54

the syntax is incorrect. mklink has the following synatx:

mklink [options] <Link> <Target>

Target is the file/folder that exists, and Link is the created one that links to the target.

so the command should be:

mklink /D "E:\Apple Computer\MobileSync\Backup"  "C:\Users\odellt1\AppData\Roaming\Apple Computer\MobileSync\Backup"

See the Microsoft Documentation for mklink usage.

Chiramisu
  • 315
26

The simplest way is to delete the Backup folder in the original Apple Computer folder on the C:\ drive, but leave the MobileSync folder be. This is because you're trying to fake the existence of the Backup folder (so it must not exist already), but you also need its parents to exist.

Then, if we run the command:

mklink /J "%AppData%\Apple Computer\MobileSync\Backup" "E:\iTunes Backups"

Windows will hence create a hard link shortcut Backup on the C:\ drive.

Mew
  • 113
Khanh.tq
  • 261
4

I had the same issue with the "file already exist error", until I used the "%AppData%':

mklink /J "%APPDATA%\Apple Computer\MobileSync\Backup" "E:\iTune Backups"

Junction created for C:\Users\Me\AppData\Roaming\Apple Computer\MobileSync\Backup <<===>> E:\iTune Backups

Note: Make sure you use straight quotes, otherwise you get a syntax command error.

Io-oI
  • 9,237
Franco
  • 41
3

I just wanted to add that the error you mentioned in your comment above System cannot find the path specified appears to happen when you are symbolically linking at a folder sub-level which doesn't exist at the link's original source.

Meaning you can't link

"c:\program files (x86)\some folder1\some folder2\"

to target

"d:\programs\some folder1\some folder2\"

It will not work unless at least

"c:\program files (x86)\some folder1"

exists as part of the link source. You would have to either link

"c:\program files (x86)\some folder1"

to

"g:\programs\some folder1" 

or you would have to create at least an empty folder at

"c:\program files (x86)\some folder1"

and then create the link

"c:\program files (x86)\some folder1\some folder2" 

to

"g:\programs\some folder1\some folder2"
Kevin Panko
  • 7,466
Kace36
  • 131
0

Ransomware Protection can also cause this when you have "Controlled Folder Access" enabled.

  1. Press the Windows Key (or click the Start Menu)
  2. Start typing "Ransomware"
  3. Open "Ransomware Protection"
  4. Click "Block History"
  5. Click to expand the most recent item (assuming you've just got the error)
  6. Click "Yes" on the UAC (User Account Control) dialog that pops up
  7. Confirm the app (e.g. cmd.exe) and "Protected folder" listed
  8. Click "Actions" and choose "Allow on device"
  9. Re-run the command
Chiramisu
  • 315