How to delete deep directory hierarchy


M

Mário

Hello,

I have a deep directory hierarchy (which was created programmatically)
having a too long path name such that I cannot delete it from explorer
or via DOS.
I tried,

rmdir /S /Q dir

but it does not work.

Does someone know how to delete a directory structure with too much
deep descendent entries?

Best Regards,
Mario
 
Ad

Advertisements

M

M Skabialka

Can you drag and drop one of the nested folders to a root folder, which will
give it a shorter path, then delete it there?
Mich
 
G

Gene E. Bloch

Hello,

I have a deep directory hierarchy (which was created programmatically)
having a too long path name such that I cannot delete it from explorer
or via DOS.
I tried,

rmdir /S /Q dir

but it does not work.

Does someone know how to delete a directory structure with too much
deep descendent entries?

Best Regards,
Mario

This thread suggests renaming as m any files as possible to on-letter
names:
http://forum.notebookreview.com/showthread.php?t=129256

This thread:
http://www.pcreview.co.uk/forums/thread-283739.php
suggests this: http://www.abtollc.com/products.aspx

If you don't like those, do what I did - Google for
delete long path name files
 
J

John John - MVP

Mário said:
Hello,

I have a deep directory hierarchy (which was created programmatically)
having a too long path name such that I cannot delete it from explorer
or via DOS.
I tried,

rmdir /S /Q dir

but it does not work.

Does someone know how to delete a directory structure with too much
deep descendent entries?

Map (over a network) or substitute (locally) the long directory path to
a drive and then delete the files from the mapped or substituted drive.
Locally, at a command prompt:

subst x: c:\long path

now you can delete file from the X drive, when done delete the
substituted drive:

subst x: /d

(Map over a network with the net use command)

Tip: You can grab folders from Windows Explorer and then drag and drop
them to the command prompt, or you can Copy & Paste to the Command line.
To substitute the current directory you can use a period:

subst x: .

will substitute the current directory to drive X.

John
 
Ad

Advertisements

M

Mário

Hello,

I finally managed to solve the problem.

Suppose that the very long path is "d:\a\mydir\mydir\mydir\...", then
the simplest solution I found was

1) Create a .bat file with this code:

@echo off
mkdir d:\b
:start
move d:\a\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir
\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir d:\b
rmdir /S /Q d:\a\mydir
move d:\b\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir
\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir\mydir d:\a
rmdir /S /Q d:\b\mydir
goto start


2) Run it.
It will finish with an error for one of the moves reporting that
either "d:\a\mydir\..." or "d:\b\mydir\..." does not exist

3) Finally, do the following

rmdir /S /Q d:\a
rmdir /S /Q d:\b

DONE!

Thanks for your posts.

Best Regards
Mário
 
Ad

Advertisements


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