Delete a very, very deep tree of subdirectories on windows?


I was testing a file management program today and while looking to solve something else my program ended up not checking for moving a directory to the same directory.

The result is a possibly endless recursion of dir1s. I need to commit the changes so I’m desperate to get these out of my repository.

Any ideas?

Basically.. what I got is:

dir/dir/dir/dir………/dir/dir/dir It’s probably on the thousands.


Are you just trying to delete the directory and all subdirectories? RMDIR /S /Q [dirname] from a command prompt should do the trick.

Try this as a workaround:

  1. At the top level of the problem directory, create another directory called ‘dummy_dir’

  2. Run robocopy dummy_dir problem_dir /purge

Answered By – JohnD

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published