2

If I rename a folder which is the target of a (or multiple) junction, is there any way to update all the junctions to point to the renammed folder instead of just breaking?

ᄂ ᄀ
  • 173
  • 2
  • 12
Mathieu Rivest
  • 123
  • 1
  • 3

2 Answers2

2

I just tried this. It doesn't work if you rename the folder as the junctions still point back to the original folder. However, a chain of junctions would work:

mkdir source
junction dest source
move source source2
junction source source2

This now means that dest links to source and source links to source2 (where source2 is the only folder containing data). I'm not sure how this works internally, though it seems to work as desired.

You have your junctions set up so you can rename the folder and link to it using the same folder name your existing junctions point to.

john
  • 1,995
  • 1
  • 17
  • 30
  • It's a bit unclean. An alternative would be to use a script to parse the existing junction points, remove them and then re-add them with the new destination. – john Jul 21 '13 at 07:26
  • WTF!?!?!? I just found out the hard way that a junction is a soft link limited to the same drive. In unixland a hard link really points to the same thing. How can you possibly break a junction link, which apparently you can? What is the different from a soft link then if it has the same functionality? Totally bewildered. – Stu Feb 13 '18 at 17:35
2

A junction target does not know about any junctions targeting to it (in other words, there's no backlink from a junction target to the junction itself). So the only proper solution requires scanning all directories for junctions and then update them accordingly.

Martin Binder
  • 231
  • 1
  • 2