Removing a deep recursive folder structure

Started by
13 comments, last by JohnnyCode 7 years, 7 months ago

Hi there,

I accidently created a very deep recursive folder structure, looking like this:

"...\Source\Runtime\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine..."

The path is naturally too long for the default Windows Explorer to remove. I attempted the popular robocopy method of mirroring the contents to an empty folder and then removing both, no success (Crashed). I also attempted the robocopy purge, no success. I attempted to use an external tool called "DeepRemove", which unsuprisingly also didn't work (Didn't crash, just told me that it couldnt delete a very deeply nested file).

I attempted a solution from StackOverflow, using the java.nio library. It was working just fine until I got this:


Exception in thread "main" java.io.IOException: Cannot access file with path exceeding 32000 characters

At this moment I'm extremely confused, as I thought the path limit on most NTFS based file systems was 32000 characters. But then again I don't know too much about file systems.

And even worse it's messing up my IDE (Clion), since this folder structure was created at the same location as the sources. And this also makes pushing very annoying (Git).

Does anybody have an idea on how to approach this?

Thanks for your time.

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

Advertisement

Is there are lot of nested folders or is there a recursive symlink of some sort involved?

If just deep folder structure, what about say

subst X: "C:\whatever\Source\Runtime\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine\Bin\Engine\Engine"

Then trying to remove stuff from there..?

There are no recursive symlinks involved I'm afraid, I checked to make sure.

I considered the subst <Name>: Path, however there are more than 10 thousand nested folders. I could consider making some sort of a script that slowly reaches the end this way, not sure if there's any consequences of creating so many "virtual" drive letters.

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

What about a script renaming folders to make the complete name shorter?

If using subst, make a script to create a single substitution that's as long as allowed. You probably don't need too much to get below the limit..?

If nothing else helps you could always try booting up a *nix live CD and mount your NTFS volume from there. I managed to delete some stubborn directories that way in the past.

@DvDmanDT:

I made a small script that renames as many folders as it can within the recursive structure, and the second stage finally worked. Again, I'm not completely sure how this is even possible, but, somehow it is.

@Prototype:

I was considering doing this, just seems like something Windows should be able to take care of ( As many other things, but let's not go there ).

Thanks out for anyone who attempted to take a shot.

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

At this moment I'm extremely confused, as I thought the path limit on most NTFS based file systems was 32000 characters.


For most core functions it is 260 bytes, including the drive letter ("c:\") and the null at the end.

There are some functions you can use in a program yourself that allow up to 32767 total bytes, but few utility functions use them.

Supposedly cmd.exe's "rmdir /s /q" can take care of this...

(Git).

Have you tried a rm -rf Engine in the git bash shell?

And try the Windows equivalent (which is Nypren's suggestion above).

I did attempt the rm equivalent (rmdir, rd), it complains that the path is too long as most other tools do.

@Frob:

Ah, I see it's slightly above 32000 characters, for some reason the library I used cut support at 32000.

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

This topic is closed to new replies.

Advertisement