We help IT Professionals succeed at work.

Created very long folder path - cannot delete (PLEASE read first)

dgrrr asked

I have read many posts here and elsewhere about related problems, and I have tried some of the solutions, but before I continue, I wanted to post so that I know I"m not wasing my time with unrelated fixes.

IN XP Home, I used cobian backup program to accidentally save "K:\*.*" to "K:\backup - live files\K drive\K\"
(that was a mistake, obviously I meant it to go onto another drive)
It was running all night, so it may have created a VERY LONG CHAIN.

It created a very long chain of subfolders - it let me browse to this point:
K:\backup - live files\K drive\K\backup - live files\K drive\K\backup - live files\K drive\K\backup - live files\K drive\K\backup - live files\K drive\K\backup - live files\K drive\K\backup - live files\K drive\K\backup - live files\K drive\K\backup - live

I renamed (shortened) as many folders as I could access, so now the path is:
K:\xdel\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\s\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\K\x\x\K\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\backup - live files\

I cannot enter, rename or move the last folder in the chain that I can access.

When I try to delete the folder it says:
Confirim file delete - the folder xdel contains items whose name is too long for the recycle bin. Permanently delete?
I say yes, then it says:
Error deleting file or folder - Cannot delete BACKUP~1: the file name you specified is not valid or too long.

I ran chkdsk /f /r for this but this did not help.

I tried RD /S (aka rmdir /s) but it said "Maximum path length exceeded". (thanks very much)

I tried the fix that uses a script and robocopy:
but that didn't work - the cmd box loaded about 10 screens of pathh names and then froze (with robocopy at 100% cpu usage)
NOTE - the path may be VERY VERY VERY LONG!

Some ppl say try xcopy too but I dno't see a delete switch. And if robocopy fails, I doubt xcopy would fail.

I tried the java app here:
but that didn't work

And I saw:
I don't want to pay for something if I don't know if it will work.

NOTE - I have seen these two fixes:
~ share the folder, then map a drive and delete from the mapped drive
~use the subst command to create a virtual drive and delete from Windows explorer all folders underneath

But so many ppl report that this does NOT WORK that I wanted to check here first.

Watch Question

Have your tried the rd command with /S switch?

rd /S <directory Name>
Sorry, I missed that line in your post. I see now that you have tried it.

Microsoft explains some stuff here http://support.microsoft.com/kb/320081

The commercial solution http://www.pathtoolong.com will probably work for you.

Dick Lewis has some interesting scripting solutions which could be adapted to your scenario:

One more suggestion: did you tried to boot form a live Linux boot CD and delete folder from there ?
i always used subst in such situations and it always worked!

You need to create a drive letter that points to the middle of
your excessively long path, either as a substituted drive or as
a shared drive:

- Click Start / run / cmd {OK}
- Type either of these commands:
subst Q: "K:\xdel\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\s\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\K\x\x\K\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\backup - live files\"

net use Q: "\\%ComputerName%\k$\xdel\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\s\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\K\x\x\K\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\K\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\x\backup - live files\"

You can now access your files from drive Q:
You're saying that the recycle bin doesn't take this long name, why don't you shift + delete them ?


I first tried deleting permanently without recycleing bin. Said "cannot delete".

I don't want to access files, I want to delete the folder path completely.

BUT > I did try SUBST and it got me further into the chain, but when I tried deleting folders within my new virtual folder, it still said, "maximum path lenght exceeded"

SO - I tried using SUBST with Q, then going as far down Q as I could, and then created drive "R", going deeper, and so on and so on, several drives in -- so I could get deep enough to start deleting - But it just kept going on, it didn't work. (Remember, the path may be very deep)

I can't see how the commercial solution would be likely to work when all these others failed. FYI the relevant dick lewis page was pay. And I doubt playing with scripts will help me with my (low) level of knowledge.
I did try boot disks (see below) - do any of then qualify as "linux" boot disks?
Also, don't I need to know linux command line stuff to get around in linux?

to ALL - and danubian:
I did try boot disks - the ulitmate bootcd 4 windows, and the (reference to that CD deleted) book disk mini xp window. Neither could delete the folder. I tried running the roboxcopy fix (above) within minixp, but it failed. I tried going to a dos prompt with (reference to that CD deleted), but it didn't see any of my local drives. (?)

Is there another boot disk option I sHould try? (I tried knoppix but I think I need to burn a new disk, it kept failing to load)

If the above does NOT include "linux boot disk" optoin, please recommend a linux boot disk, and at least a tutorial on what commands I need to know. (I know nothing about linux command lines!)

thanks guys!
References to a well-known CD that contains pirated software removed.  We don't allow any instances of the CD on this site.

Please refrain from posting references to any CD that rhymes with Siren's.

Alan Hardisty
Zone Advisor

Open in new window

I contacted the creators of Cobian, and they told me to use Cobian's built in "Deleter" tool. And it worked. (took about 10 mins)

I'm curious how it works so I asked him - will post here when he responds.
It makes sense that if they have a tool that can create this mess for you, that they should be able to help you out of it with a different tool. Because they can obviously write these ridiculous long path names, deleting it should be included as well.

I am glad that you were able to get it corrected.


agreed. I also think it would be wise for any backup program to automatically warn the user any time he or she is backing up a directory to somewhere inside of that same directory. (is there a name for that?)

The tool refers to "recursive deletion", but all deleters do that, right? Just means it keeps repeating some process until the result is achieved, right?

Sorry for the late answer.
You could use http://www.ubuntu.com/desktop/get-ubuntu/download as an alternative Live CD. Burn the downloaded image and boot from CD  (you have to select "Try" to not install it, just run). Is not needed to be a Linux expert to make some files management with a live CD. There is a GUI interface.

Anyway, good to know you found a tool.


Here's cobian's answer, regarding how his "deleter" tool works:

"You just need to pass the name of the files to delete with the prefix
\\?\ and use the unicode API functions (DeleteFileW)."

I don't know anything about the windows api (had to google it), but the issue of too long folder paths often seems to require unicode vs ansi version.