I seem to have managed to get an Application Data folder recurse into itself somehow, doesn't look recursive but somehow still is and now I find myself unable to remove that folder. The folder itself is merely a subfolder in a backup folder from an old pc. It isn't used anymore in any way.

Current folder name is


(I renamed Documents and Settings to toremove)

Following I have tried

  • Delete in explorer.

    enter image description here

  • rmdir /s /q .
  • chkdsk. This reports a Windows may not detect all cycles on your volume because the directory structure is too deep.
  • robocopy to mirror an empty folder into the recursive one. This crashed robocopy with a stack overflow: STACK_OVERFLOW_c00000fd_Robocopy.exe!RoboPrune
  • Rename Application Data recursively to t to shorten the path length. This stops with the message that the fully qualified name must be less than 260 characters

    $current = gci "C:\DWI00672\toremove\brhi\AppData\local" -Force 
    while ($true) {
      if ($current.BaseName -ne "t") {Rename-Item -Path $current.FullName t -ErrorAction Inquire -Force }
      $current = gci "$($current.Parent.FullName)\t" -Force -ErrorAction Inquire 
  • Download TeraCopy and try it having remove the folder.

  • subst into the folder structure to furter shorten the path using the Powershell script. After drive K:, I gave up.enter image description here
  • junction -s from sysinterals but this finds no reparse points. enter image description here
  • dir /s c:\DWI00672\toremove\brhi\AppData\Local is currently listing 330 Dir(s)
  • dir /al /s c:\DWI00672\toremove\brhi\AppData\Local to list the Reparse Points is returning File Not Found
  • rm -f -d c:\DWI00672\toremove\brhi\AppData\Local from Cygwin executed as current user, administrator and as system (psexec -s -i cmd). The all return rm: cannot unlink 'local': Not owner. The owner of the Local folder is my current user.
  • It's possible that somewhere under the Local folder (in one of it's many sub folders, or sub sub etc) there is a SymLink called Local to the real Local folder. This would certainly create a cycle. (See the clue in the message "cannot unlink 'local'" - may not be correct but it is suggestive.) – simon at rcl Jan 25 '17 at 15:04
  • Possible but dir /al /s and/or junction -s should have found those. Let's assume that's right, any idea how to remove the folder structure? – Lieven Keersmaekers Jan 25 '17 at 16:24
  • 1
    This question's subject matter attracts a number of very persistent spammers. Protecting the question prevents them from posting. – Michael Hampton Jan 26 '17 at 6:21

Unfortunately, I can't comment.

But, you could try to use robocopy to mirror an empty directory to C:\DWI00672, then remove the directory.


  1. mkdir C:\empty
  2. robocopy C:\empty C:\DWI00672 /PURGE
  3. rmdir C:\empty
  4. rmdir C:\DWI00672

Robocopy doesn't use the same system calls that have the 248 character limit. But it might have an upper character limit I'm not aware of.

I just tried it on my system, it worked just fine (this had a folder structure of around 400 characters).

  • I tried and listed that, it didn't work: robocopy to mirror an empty folder into the recursive one. I just tried it again with the /PURGE parameter but it crashes with a stack overflow.Following is the failure bucket id: `STACK_OVERFLOW_c00000fd_Robocopy.exe!RoboPrune`` – Lieven Keersmaekers Jan 26 '17 at 6:14

protected by Michael Hampton Jan 25 '17 at 21:36

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.