Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On one of our Windows 2003 file servers somehow someone or something managed to create infinitely recurring directory trees within some of the users' home folders, and they can't be deleted.

You wind up with something like this:


And it continues infinitely as far as I've been able to tell.

Trying to delete the directory tree from the system it resides on results in "Error deleting file or folder: Cannot delete file: ". Trying to delete it from a Windows 7 system connected to the network share results in a "folder in use" error.

If you navigate down the directory tree as far as you go you eventually reach a directory that cannot be opened or deleted (if right clicked none of the standard options appear), however if you try to open the same directory from a share on another system it can be opened, however Windows Explorer becomes extremely slow.

I've tried the suggestions in this post, as well as booting the server with a Linux disc and trying to rm -rf the directory, neither worked.

It is a mystery.

Edit: I might also add that it's possible to rename the directories, just not remove them.

share|improve this question
A similar issue was resolved on Server Fault. – Lilienthal Feb 13 '15 at 18:59

It's possible that whomever was working in that folder manage to create a junction point that loops back up from to servername, thus creating a the 'infinite loop' directory tree.

Junctions are a feature of the NTFS file system that lets you create a symbolic link to a directory that operates as an alias to the directory.

You can see under the "Observed Effects" section of the wiki page the problem you describe.

Try running this utility to list junctions under that server:

It should also give you the ability to delete the junction point.

share|improve this answer

It's possible that there's a Symbolic Link to a folder somewhere, most likely the second student in your path.

Try executing the command:

dir D:\Student\2012\\servername

and see whether student is marked as DIR or SYMLINK/JUNCTION.

For example, this is a typical output of the dir command:

04/24/2012  10:58 PM    <DIR>          .
04/24/2012  10:58 PM    <DIR>          ..
04/24/2012  10:58 PM    <SYMLINKD>     a [h:\a]

You see that the first two entries are marked as DIR, while the third (a symbolic link to another folder) is marked as SYMLINKD. In your case (Windows 2003) I think there are JUNCTIONs instead of SYMLINKs.

If the student folder is a symbolic link or junction, run the commands:

cd /d D:\Student\2012\\servername
rmdir student

and thus get rid of the recursion.

share|improve this answer
None of the directories are symlinks, I checked the first couple plus the one at the "end" where it gets stuck. – EnglishInfix Apr 24 '12 at 20:27

I had a similar problem when eclipse created a massively deep folder tree which I couldnt delete. However since it was possible to move and rename folders I wrote a batch file to work it's way down the tree deleting folders one at at time and this worked! For a apparently infinately deep folder tree of FOLDERNAME in the C directory, i.e.


Batch file :

GOTO LoopStart

This works because TEMPFOLDERNAME is now a tree of finite length (a single folder with nothing in it) and the massive FOLDERNAME tree has one less folder every time the loop is run, eventually reaching the bottom by removing a folder at the top.

share|improve this answer

I did run into the same issue with a 5000+ directory-deep folder mess that some Java application did and I wrote this:

It removed the whole thing after a while, but it managed to do the job, I hope it helps people who (as I), run into the same frustrating issue

share|improve this answer

I had the same problem. The folder I wanted to delete contained an endless tree of links to the same name and every attempt to delete it caused Windows to throw a "File too long..." error. It failed regardless of the command I tried including all the above methods so I tried Cygwin's "rm" command in a cmd window just above the folder in question. I entered "rm -r -f [folder]" and the folder was deleted without complaint.

You can download Cygwin for free from Its basically a UNIX shell for Windows that contains all the common commands (e.g., ls, rm, du, and cat) but also has a ton of packages that if all were downloaded would take up about 1GB of space. I believe the default download package includes the UNIX commands. If not, they're in the "utils" bundle if memory serves.

NOTE: You need not run Cygwin commands in its native bash shell window. They can be run in a cmd window by adding the path to cygwin's "bin" directory to your system PATH environmental variable. In my case I added "C:\cygwin64\bin".

I hope this helps.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .