I created a symlink using
mklink. Now I need to change it but I can't figure out how to delete it so I can recreate it correctly.
Be very careful.
If you have a symbolic link that is a directory (made with
mklink /d) then using
del will delete all of the files in the target directory (the directory that the link points to), rather than just the link.
rmdir on the other hand will only delete the directory link, not what the link points to.
In Powershell, don't use
cmd /c rmdir .\Target instead. I tested this myself and confirmed it here: http://kristofmattei.be/2012/12/15/powershell-remove-item-and-symbolic-links/
mklink cannot be used to delete symbolic links. To remove a symbolic link, simply delete them as if you’re removing a normal file. For example, to delete the foo symbolic link created above, enter the following command:
If the link is a hard link to a directory:
or else, IF the link points to a file (as opposed to a dir)
In my case (Windows 10), after creating the symbolic link using
MKLINK /D "C:\Users\username\Dropbox\MyProject" "C:\SourceProject"
and deleting via delete using the file explorer or keyboard delete key also deletes the original directory.
What you should do is to remove the link via command prompt.
C:\Users\username\Dropbox>rd /s MyProject
For details about the rd command: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rd