MKLINK (symbolic link) not working

symbolic-link

I am trying to create a symbolic link on my Windows 10 64bit to redirect the iTunes backup file to my external hard disk (D:\)

This is the link I added in my command window:

mklink /J "%APPDATA%\Apple Computer\MobileSync\Backup" "D:\iTunes Backup"

It didn't work fully as the backup file was still created in the parent directory (C:\) even though the same file was also created in D:\

Now I can't complete my phone backup because I do not have enough storage.

Why were two files created ?

Best Answer

Why were two files created?

mklink /J "%APPDATA%\Apple Computer\MobileSync\Backup" "D:\iTunes Backup"

The above command is broken. The syntax for mklink is:

MKLINK [[/D] | [/H] | [/J]] Link Target

where link is the "The new symbolic link name", so not the name of a directory including the full path.

In addition, you can't make a link where the name already exists.

If you were in directory "%APPDATA%\Apple Computer\MobileSync" and you tried the command:

mklink /J Backup "D:\iTunes Backup"

Then you would have received an error:

Cannot create a file when that file already exists

Note the error message says a file already exist instead of a folder. This is because the system sees links as shortcuts (files) and not as folders.


How do I redirect the iTunes backup file to my external hard disk?

Use the following procedure:

  1. Create D:\iTunes Backup if it doesn't exist. Now you have a target for the junction:

    md D:\iTunes Backup
    
  2. Go to the existing backup directory:

    cd "%APPDATA%\Apple Computer\MobileSync\Backup"
    
  3. Move any existing files to D:\iTunes Backup:

    move * "D:\iTunes Backup"
    

    If there are any folders move those as well.

  4. Go up one directory to "%APPDATA%\Apple Computer\MobileSync\:

    cd ..
    
  5. Delete the backup directory:

    rd Backup
    
  6. Create the junction:

    mklink Backup "D:\iTunes Backup"
    

    You should see a message like:

    Junction created for Backup <<===>> D:\iTunes Backup


Further Reading