Earlier this weak I was cleaning up virtual server for another round of torturous (to me) software experiments. I’ve noticed that one of heavy applications claimed to uninstall correctly, but left folders behind. Folders I was unable to delete.
After few attempts and tools like Unlocker failed (sadly I had no access to Total Commander at moment) I tried to simply browse those folders and umpteenth levels deeper I got message that path is too long to navigate.
Microsoft offers extensive knowledge base article “You cannot delete a file or a folder on an NTFS file system volume”. In short it tells you that very long paths are pain to kill so you better look for software that can do that or enjoy intricate operation of remaining folders until path isn’t too long.
I’d prefer to read that they taught Explorer to do perform its file managing duties with at least some kind of effort to not fail miserably.
What it does
Since article offered no explanation, except mention that it relies on robocopy I decided to look into it. Turns out it uses robocopy in rather clever way.
- Takes folder to delete as command line parameter.
- Creates empty folder in system temporary folder.
- Runs robocopy, instructing it to copy empty folder over target and destroy everything that is absent in former ( /MIR key).
Essentially robocopy is instructed to overwrite target folder tree and files in it with empty directory. And, as I tested, it does an excellent job – without any issues with long path.
As usual I must warn that such kind of script can be extremely destructive, use cautiously.
It would have never occurred to me to use robocopy in such way. It shows just how powerful modern command line utilities can be, despite seemingly archaic interface paradigm.