I’m about to pop a new SSD into my main desktop, and before doing so I figured I’d save some time and copy the contents of my C:\ onto a data drive for easy reference. I had plenty of space on my data drive, so why not? I’ve got a load of scripts lying around that use robocopy to back data up, so I thought that’d be as good a way as any.
The Robocopy died as my disk had run out of space. Huh? The target volume had over 400gb free on it, and my current SSD was only 150gb, that math doesn’t seem right. So I tried to delete the folder on my data drive, only to receive errors about the filenames being too long to delete. Whaaa?
So it seems the problem and the solution are pretty obvious. By default, Robocopy will attempt to copy junction points unless you include the /XJ parameter, which can leave you with a recursive mess.
The fix is quite easy, use Robocopy! Create an empty directory and run Robocopy against that and your messed up directory with the /MIR parameter and all will be tidied up. There’s more information here, on Superuser.com for anyone interested.
It’s a very humbling experience when you get yourself in a mess with a tool that you use daily!