 |
 |
 |
| |
Deleting folders longers than 255 |
View full version |
|
User #16184 415 posts
Forum Regular
|
Hello All
Just wondering if anyone knows how to delete folders that are more than 255 characters deeps.
I'm restoring a stuffed raid, as part of the restore it's gone a little nuts with some folders.
I have heaps of folders that are way longer than 255, and deleting them manually is a pain in the ass.
Just wondering if anyone know of a prog, that will truncate them.
Regards, Scott
|
posted 2005-Dec-1, 4pm AEST
|
|
User #40586 18161 posts
Senior Moderator
|
Scott Harris writes... Just wondering if anyone know of a prog, that will truncate them.
For future reference here is the spill from the relevant MS KB article
Resolution 1: Use an auto-generated 8.3 name to access the file
To resolve this issue, you may want to use the auto-generated 8.3 name to access the file. This resolution may be the easiest resolution if the path is deep because the folder names are too long. If the 8.3 path is also too long or if 8.3 names have been disabled on the volume, go to Resolution 2.
For additional information about disabling 8.3 file names on NTFS volumes, click the following article number to view the article in the Microsoft Knowledge Base: 121007 (support.microsoft.com/kb/121007 ) How to disable the 8.3 name creation on NTFS partitions
Resolution 2: Rename or move a deep folder To resolve this issue, rename the folder so that the target files that are deeper than the MAX_PATH no longer exist. If you do this, start at the root folder (or any other convenient place), and then rename folders so that they have shorter names. If this step does not resolve this issue (for example, if a file is more than 128 folders deep), go to Resolution 3.
Btw what MS means by 8.3 names is say I had a folder abcdefaghijklm it would be abcdef~1, and if you had abcdefzzzzzzzzz that would be abcdef~2.
You can then use batch files to work with those files as you see fit.
If the partitions are FAT I would use a Linux live cd myself. If it is NTFS, stick to windows.
Edit: Apologies for making that over complex, the solution below will work fine for deleting, I focused on working with the files. I just tested it by making a 500 char long file path using Linux and deleting it using Windows.
|
posted 2005-Dec-1, 5pm AEST
edited 2005-Dec-1, 5pm AEST
|
|
User #41025 2640 posts
Whirlpool Forums Addict
|
open the command prompt, then:
C:\> rmdir /s /q c:\your\directory\deletethis
|
posted 2005-Dec-1, 5pm AEST
|
|
User #16184 415 posts
Forum Regular
|
thanks for your replies
but rmdir /s /q doesn't work, i've already tried that.
These directories are bloody huge, for exmaple
some are over 50 folders deeps and the folder names are 20 char longs.
they look like this.
7000.232___23232.4_0003.00001
any like i said 50 deep.
There must be a program out there that can find these directories and delete them or truncate them to a manageable size.
At least i hope there is :).
Scott
|
posted 2005-Dec-2, 8am AEST
|
|
User #40586 18161 posts
Senior Moderator
|
Scott Harris writes... There must be a program out there that can find these directories and delete them or truncate them to a manageable size.
I've done a fair bit of looking and I can't seem to find one.
Something worth trying though is going to the top of a large group of folders nearest to the 255 limit you can get to and running the subst command.
e.g. subst X: "C:\really\long\path\that\is about 250 characters\"
then change to X: and run rmdir /s /q from there and keep moving down the tree as needed.
to remove the substituted drives use subst X: /d
|
posted 2005-Dec-2, 4pm AEST
edited 2005-Dec-2, 4pm AEST
|
|
User #10062 4581 posts
Whirlpool Forums Addict
|
try doing a dir /x
it will then give you the representation in 8.3 format which will allow you to remove/delete things
damn just noticed someone said this :-)
|
posted 2005-Dec-2, 7pm AEST
edited 2005-Dec-2, 7pm AEST
|
|
User #40586 18161 posts
Senior Moderator
|
narkotix writes... damn just noticed someone said this :-)
You called :P
it will then give you the representation in 8.3 format which will allow you to remove/delete things
The problem more seems to be with the rmdir (deltree replacement) command and the api calls it uses to delete the files, they must be limited in terms of directory depth or path length.
Hence you want to shorten one or more of those if possible.
|
posted 2005-Dec-2, 7pm AEST
|
|
User #16184 415 posts
Forum Regular
|
Hello All
I found the easiest way to delete these dam directories was just keep renaming them.
So after a few hours and renames thousands of folders, i've deleted them all.
MY fingers are killing me and my brain feels like i've been playing bf2 48 hours straight.
The answer the my question is there is no easy way. Better off avoiding it from the start.
But it's done. Thanks for your help.
Scott
|
posted 2005-Dec-3, 10am AEST
edited 2005-Dec-3, 10am AEST
|
|
User #52985 670 posts
Whirlpool Enthusiast
|
LOL.... I was going to suggest something like FAR (from the makers of RAR)... a replacement to the good old DOS semi-GUI file managers.
Might have helped, but it's done now.... so it doesn't really matter :)
|
posted 2005-Dec-3, 10am AEST
|
|
User #16184 415 posts
Forum Regular
|
i tried the old dos Disk Commander. It didn't work.
|
posted 2005-Dec-3, 10am AEST
|
|
User #34171 3048 posts
Whirlpool Forums Addict
|
I was almost able to save you some typing last night but Windows threw a BSOD after I had written the batch files but before I could post or save the damn things.
It wasn't a fully automated solution and it was kind of ugly but it probably would've worked.
|
posted 2005-Dec-3, 12pm AEST
|
|
User #16878 4096 posts
Whirlpool Forums Addict
|
the subst command might have helped.
If you had files in a subdirectory which was called e.g. This\is\a\very\long\file\name\whic h\will\eventually\reach\or\exceed\ the\twohundredandfifty-five\charac ter\path\and\file\name\length\impo sed\by\the\command\shell\in\window s\but\if\the\sub-folders\and\files \are\all\in\different\branches\fro m\the\root\then\the\proposed\metho d\would\not\work\as\the\remaining\ path\must\still\be\less\than\255ch aracters
(Ignore any spaces which Whirlpool automatically adds to long text) then you could use e.g. subst m: This\is\a\very\long\file\name\whic h\will\eventually\reach\or\exceed\ the\twohundredandfifty-five\charac ter\path\and\file\name\length\impo sed\by\the\command\shell\in\window s\but\if\the\sub-folders
and then m:\and\files\are\all\in\different\ branches\from\the\root\then\the\pr oposed\method\would\not\work\as\th e\remaining\path\must\still\be\les s\than\255characters
is less than the 255 limit.
|
posted 2005-Dec-3, 1pm AEST
|
|
User #16184 415 posts
Forum Regular
|
i ended up finding that just continually moving the folders to the root of the drive was quickest.
For example, i would move the folder that was as deep as i could go, then deleted it. Then i would go to the moved folder, go in as deep as i could go then move it and then delete it.
Was quicker and easier of the brain than renaming all of them.
I wish i could has remember how to create a batch file to do the job, but i thought it would take me just as long to create the batch file as it would be to just fix the problem. :)
Scott
|
posted 2005-Dec-5, 6pm AEST
|
|
User #40586 18161 posts
Senior Moderator
|
Scott Harris writes... but i thought it would take me just as long to create the batch file as it would be to just fix the problem. :)
Fair Enough. It is sometimes in those situations you learn the most, but unfortuantley have the least time to learn it :P
For example, i would move the folder that was as deep as i could go, then deleted it. Then i would go to the moved folder, go in as deep as i could go then move it and then delete it.
Ended up being very similiar to my intention with the subst command, if a little more convulted.
|
posted 2005-Dec-5, 10pm AEST
|