How to Delete Paths Longer Than 260 Characters on Windows

There are times somehow someone or some process managed to create files or directories longer than 260 character limit on Windows. If you try to delete them, Remove-Item or any other delete attempt errors out because well, Windows can’t really handle the long path well.

Here is a trick. Robocopy can deal with something like that pretty well. Here are the steps.

  1. Create an empty folder such as C:\empty
  2. Execute the following robocopy command to mirror the empty folder with the destination folder you want to clean up.
    robocopy C:\empty C:\some\path\you\wanna\clean /MIR

    Rocopy for the rescue!


Leave a Reply

Your email address will not be published.