mklink error: Cannot create a file when that file already exists
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.
Solution 1:
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.
Solution 2:
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.
Solution 3:
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.