Cannot delete very deep directory tree

T

tedbaab

Hi everyone, I have an unusual problem:

I have a directory that I cannot delete that was created by an
accidental backup routine. I have a folder on my K drive called "K:
\projects 2007" with about 89mb (3 folders) in in, which was copied by
my automated backup (Cobian Backup) into its own directory "K:
\projects 2007", creating a loop that nested "projects 2007" folders
into themselves, presumably with about 89mb in each tier. Creating:

K:\projects 2007\projects 2007\projects 2007\projects 2007\projects
2007\projects 2007...

I do not know how deep the directory structure goes, but by the space
left on my disk, it looks to be about 433 directories deep (for a
total disk usage of about 39GB)! My goal is to delete the whole thing.

I cannot delete, it says "Cannot Delete File or Folder, Cannot Delete
File:".

I have tried:

1) Going down as far as I can and trying to delete that folder. Same
problem, presumably because I am only like 18 levels down, which
barely scratches the surface! Explorer will only let me browse that
far.

2) Terminating explorer and browsing from within Nero to delete the
folder, or a deeper one within it. It only lets me browse down to like
18 tiers anyway.

3) using the Command Prompt, after having terminated explorer, and
from safe mode to rmdir /s the directory. I have also tried the rd
command. Both successfully bury through an impressive number of
directories, but return lots of errors like "Maximum Path Length
Exceeded", "The process cannot access the file because it is being
used by another process" (even from safe mode), "The directory is not
empty", etc etc

4) Browsing down as far as I could go (again, like 18 tiers), then
mapping that folder to a new virtual drive, then browsing down in that
virtual drive, then mapping a deeper drive, etc. I used all 26 letters
and was able to browse deeper, but I get the same error when I try to
delete a folder.

5) I have tried numerous "Delete on Boot" programs to attempt to
delete the folder on reboot, when nothing was accessing it.

Any thoughts or suggestions short of clearing off the drive and
formatting, would be much appreciated!

Thanks again

Ted
 
J

John John

Try using the SUBST command to shorten the path or map it to a network
share then try to delete it.

John
 
G

Guest

Can you rename the folders? If so, you could try a batch job like:

set kren=k:
:loop-awhile
rename "%kren%\projects 2007" "%kren%\k"
set kren=%kren%\k
goto loop-awhile

This might eventually shorten the total path name enough that Windows can
deal with it.
 
T

tedbaab

Can you rename the folders? If so, you could try a batch job like:

set kren=k:
:loop-awhile
rename "%kren%\projects 2007" "%kren%\k"
set kren=%kren%\k
goto loop-awhile

This might eventually shorten the total path name enough that Windows can
deal with it.

davidson, that sounds like a great strategy. how would i go about
doing that? I am not so knowledgeable about batch files. I would also
need to run this either from safe mode, or from cmd with explorer shut
down since it says the folder is being used/accessed when i try to
rename a folder from explorer...
 
G

Guest

Just copy and paste the code into a file named temp.bat or temp.cmd, then run
the file from the command line. Here's a slightly better version of the
script, with error checking.

set kren=k:
:loop-awhile
rename "%kren%\projects 2007" "%kren%\k"
if errorlevel 1 exit /b
set kren=%kren%\k
goto loop-awhile

If this works, but doesn't get you far enough, do a SUBST command and change
the K: in the first SET command to whatever letter you assign.

Good luck!
 
T

tedbaab

Just copy and paste the code into a file named temp.bat or temp.cmd, then run
the file from the command line. Here's a slightly better version of the
script, with error checking.

set kren=k:
:loop-awhile
rename "%kren%\projects 2007" "%kren%\k"
if errorlevel 1 exit /b
set kren=%kren%\k
goto loop-awhile

If this works, but doesn't get you far enough, do a SUBST command and change
the K: in the first SET command to whatever letter you assign.

Good luck!

davidson,
thanks for your quick reply and your explanation.

I tried the first script (without the error checking), and it did it
for a while (2033 times actually), before saying the input was too
large. But that at least means there are 2033 or more nested
directories. But for some reason, none of the directories that I can
browse from explorer had the names changed.

When I used your new script, it errored out immediately, and did not
complete one iteration.

am I stuck then?

Thanks again, you've been very helpful!
 
?

=?iso-8859-1?Q?_db_=B4=AF`=B7.._=3E=3C=29=29=29=BA

you might try uninstalling
cobian then trying to
delete that directory n files.

or try the delete them
via safemode.

or simply move out
whatever you can from
the k partition. then delete
the partition and recreate it
if you still need it.

--

db ·´¯`·.¸. , .


..
 
G

Guest

The first version errored out when the command string got too long for DOS to
manage, not when it ran out of folders to rename; that's why I added the
error check. Toward the end, were you getting "system cannot find the path"
or "filename is too long"?

The second version errored out immediately because it assumes the first path
is still named "projects 2007" and (hopefully) some of the upper levels had
already been renamed. Either that, or my original RENAME command was bad.
Check that the folder name is spelled correctly, and such like.

Does the original folder still appear when you type DIR K:\ at the command
prompt? If the original "projects 2007" folder still exists, there was a
problem with the original rename. If it's been renamed to K:\K, then at
least the upper-level renames worked.

If the top-level folder is still there, can you rename it manually?
 
P

Poprivet

Hi everyone, I have an unusual problem:

I have a directory that I cannot delete that was created by an
accidental backup routine. I have a folder on my K drive called "K:
\projects 2007" with about 89mb (3 folders) in in, which was copied by
my automated backup (Cobian Backup) into its own directory "K:
\projects 2007", creating a loop that nested "projects 2007" folders
into themselves, presumably with about 89mb in each tier. Creating:

K:\projects 2007\projects 2007\projects 2007\projects 2007\projects
2007\projects 2007...

I do not know how deep the directory structure goes, but by the space
left on my disk, it looks to be about 433 directories deep (for a
total disk usage of about 39GB)! My goal is to delete the whole thing.

I cannot delete, it says "Cannot Delete File or Folder, Cannot Delete
File:".

I have tried:

1) Going down as far as I can and trying to delete that folder. Same
problem, presumably because I am only like 18 levels down, which
barely scratches the surface! Explorer will only let me browse that
far.

2) Terminating explorer and browsing from within Nero to delete the
folder, or a deeper one within it. It only lets me browse down to like
18 tiers anyway.

3) using the Command Prompt, after having terminated explorer, and
from safe mode to rmdir /s the directory. I have also tried the rd
command. Both successfully bury through an impressive number of
directories, but return lots of errors like "Maximum Path Length
Exceeded", "The process cannot access the file because it is being
used by another process" (even from safe mode), "The directory is not
empty", etc etc

4) Browsing down as far as I could go (again, like 18 tiers), then
mapping that folder to a new virtual drive, then browsing down in that
virtual drive, then mapping a deeper drive, etc. I used all 26 letters
and was able to browse deeper, but I get the same error when I try to
delete a folder.

5) I have tried numerous "Delete on Boot" programs to attempt to
delete the folder on reboot, when nothing was accessing it.

Any thoughts or suggestions short of clearing off the drive and
formatting, would be much appreciated!

Thanks again

Ted

Since this is K drive, presumably NOT your boot drive, then just copy
everything BUT that folder set to another drive. Then kill, recreate the
partition, and put things back. Done, quicker, and more efficiently.

AND, if that program can't handle recursing itself, I'd get rid of it and
install one that can! That's an unforgiveable bug, IMO. Any good app knows
not to recurse itself.

If you're doing that with batch files, XXCOPY will handle that sort of
recursivity very well and easily. It's at xxcopy.com. Very similar to
xcopy but much more powerful. Oh, and it's free but I found it so useful I
paid for it. Only difference between paid/free is a license, which stops
certain nags and turns on a few very powerful features. It'll also clone a
drive; has both backup and clone features. NOT for backing up system
drives; you need to use shadowcopy for that. It's all in their FAQs.

HTH

Pop`
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top