Windows 7 Delete heavily nested folder structure

8

3

I was running a node script that went awry and created a folder structure like so:

\myfolder
    \myfolder
    \file.txt
        \myfolder
            \file.txt
                \myfolder
                \file.txt
                    \etc.

This is nested to an extent of over 300 times, I would estimate, if not more.

I cannot del it because it is too long a file path.

I cannot use robocopy because it actually freezes around this point:

enter image description here

I cannot use FileAssassin as it is only for files apparently.

I have tried using the .bat script from this answer How do I delete a folder which is nested quite deep and avoid "File name too long"? , and it is still running, but I fear at the level of recursion that the folder is at even if every single subfolder was renamed to one character it would still be longer than 260 (or whatever the limit is).

How do I remove this problem from my filesystem?

EDIT

DeepRemove is successful! Victory! 3,421 levels of recursion. Jeesh! I'll be more careful with nodejs (or any programmatic modification of the filesystem) from now on, esp. when recursion is involved!

Aristides

Posted 2014-02-16T15:20:52.987

Reputation: 195

Question was closed 2015-10-27T18:39:43.793

Did you try deleting the root folder? – and31415 – 2014-02-16T15:30:23.970

@and31415 yes. the file path is too long for windows to handle it itself. – Aristides – 2014-02-16T15:31:28.963

2Maybe someone will come up with a better solution, but what about booting on a GNU/Linux Live-CD, mounting the Windows partition and just rm'ing the problematic directory ? I think that Linux'es file path limit is way longer than Windows'es so it may work. – None – 2014-02-16T15:34:30.703

@André that might work, but it is probably my last resort. – Aristides – 2014-02-16T15:41:36.577

@Aristides Yeah, just making sure. Now it would be interesting to know what actually created the problem in first place. – and31415 – 2014-02-16T15:42:13.417

@and31415 as I said, runaway nodejs script. Still not sure how :) – Aristides – 2014-02-16T15:42:46.677

@Aristides Have you got any source you can share? – and31415 – 2014-02-16T15:48:03.843

I was using this: https://github.com/btwael/mammouth and I believe I accidentally switched up the "compile" and "output" dirs causing some recursion glitch.

– Aristides – 2014-02-16T15:49:10.707

@and31415 rmdir did not work. – Aristides – 2014-02-16T15:50:01.570

@and31415 Will try Linux live distro as last resort. – Aristides – 2014-02-16T15:57:00.590

Answers

8

I have not tried this software but you may want to review it and give it a go.

https://deepremove.codeplex.com/

Good Luck.

Jim

Posted 2014-02-16T15:20:52.987

Reputation: 154

1

For posterity I'm sharing SiloSix's solution.

He created a bat file to move the folder structure around and delete small chunks at a time. It's simple and beautiful. (I also had several thousands folders to deal with.)

It worked on my problem in less than 2 minutes.

REM https://superuser.com/users/151251/silosix
D:

REM  CD deep into the problem directory...
cd D:\a\calculator.sikuli\calculator.sikuli\calculator.sikuli\calculator.sikuli

REM Move the rest of the problem dir to a temporary parent folder
move /-Y calculator.sikuli D:\b

REM CD to the temp folder
cd D:\b

REM delete the section of problem-dir above
rd /s/q D:\a\calculator.sikuli

REM Move the rest of problem-dir back to origin
move /-Y calculator.sikuli D:\a

REM Call the script until problem directory is gone!
call D:\remdirs2.bat

The REM tags are just comments, they can be left in or taken out as you please. (In case the next person to find this isn't versed in bat scripting.)

Squish

Posted 2014-02-16T15:20:52.987

Reputation: 119

I think that DeepRemove is an easier solution, esp. someone not well versed in using the command line. – Aristides – 2014-10-07T23:08:01.557

2@Aristides By the time I stumbled on this my directory issue has been resolved uaing the batch script so I wasn't able to test DeepRemove out. Some other tools created to solve the same problem hadn't worked, though. So I figured re-posting the script might be beneficial for anyone who stumbled across this. :) – Squish – 2014-10-07T23:15:57.903