Deleting Folders With ‘Long Filenames’ (Source Path Too Long)

KB ID 0001396

Problem

Source Path Too Long

Source Path Too Long
The source file name(s) are larger than is supported by the file system. Try moving to a location which has a shorter path name, or try renaming to shorter name(s) before attempting this operation.

“Have you come across a problem deleting folders with long filenames?” I got asked this question twice in the first week at a new job. In a former role my colleague did a lot of work in schools and was forever coming across this problem when doing file migrations.

As it transpired this was a problem at, yes you’ve guessed it a school that was a client. The little darlings had got hold of a script that recursively created nested folders, and as obviously this is hilarious it had happened multiple times.

I didn’t have a solution of the top of my head, but I thought I’d try and recreate the problem, and see if there was a simple solution.

Solution

The most difficult part was replicating the script. Windows is pretty good at protecting itself. But thanks to the good folk at Experts-Exchange’s assistance, I was good to go, attempting to move or delete the file generated the error you see above.

Method One: Use Robocopy

Robocopy has been built into windows for a while, you can use it with the /MIR flag to remove all your subfolders.

MD C:\DELETE-ME
robocopy C:\DELETE-ME C:\{path}\{The Top Level Folder To Delete} /s /mir

Cannot delete path too long

Then you can simply delete the two remaining empty folders

rd C:\DELETE-ME
rd C:\{path}\{The Top Level Folder To Delete}

Delete Long File Path

Method Two: Use a GUI Tool

I’m always suspicious of third party tools, and if you Google this problem two pieces of software will jump out, one’s brilliant does not have any spamware or malware in it, the other one’s, well not free and annoying.

The Good

Delete Long File Path GUI

DeleteLongPath by BackupChain simple and does exactly what you expect. Take some time to look a their backup software as well!

The Bad

Message boards are spammed with people saying how great this piece of software is, probably by the clowns who make it! Long Path Tool, they just want your money don’t bother. 

Update: I’ve had about 15 to 20 chancers trying to post favourable comments for this piece of junk, don’t bother i wont approve them!

Dont Buy Long Path Tool

 

Related Articles, References, Credits, or External Links

NA

Author: PeteLong

Share This Post On

7 Comments

  1. ROBOCOPY /MIR /S worked great to remove a folder with “Source path too long” error.

    BTW) the way the folder got created with too long path was I was robocopying a user profile to a network share for roaming profiles. I forgot to use the /XD flag (ignore junction) so it kept creating recursive directories. It also filled up my file server and caused quite a panic!!!

    Post a Reply
    • @nat excatly the same as what happend to me!

      Post a Reply
  2. I am using robocopy for long time but never thought in this way. hats off to you sir.

    Post a Reply
  3. Robocopy…I loved the Logic Mate…Saved me a lot of time.

    Post a Reply
  4. Brilliant! Thanks so much, I spent hours trying to delete one file.
    Backup Chain is perfect. Does what you say, no trubba.

    Post a Reply
  5. The RoboCopy solution you gave is a work of art!

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *