KB ID 0001396
Problem
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
Then you can simply delete the two remaining empty folders
rd C:\DELETE-ME rd C:\{path}\{The Top Level Folder To Delete}
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
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!
Related Articles, References, Credits, or External Links
NA
23/05/2019
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!!!
13/06/2019
@nat excatly the same as what happend to me!
03/07/2019
I am using robocopy for long time but never thought in this way. hats off to you sir.
28/11/2019
Robocopy…I loved the Logic Mate…Saved me a lot of time.
01/06/2020
Brilliant! Thanks so much, I spent hours trying to delete one file.
Backup Chain is perfect. Does what you say, no trubba.
25/11/2020
The RoboCopy solution you gave is a work of art!
27/11/2020
Cheers Dave 🙂