Question
Currently, I'm having problem deleting an old Folder. Previously, I used its parent as a shared folder, but one day when I tried to clear that folder there is one folder that has duplicate. The problem is one of them (the old one) can't be deleted even after I deleted all files/folders in that folder, I can't remove/rename that folder (could not find this item) not even with cmd as Administrator. I've tried to defrag my Windows Sever 2012 but the problem still persists. How to fix this problem?
Solution
I had this same problem using Server 2012 Std. I tried various options of taking ownership of the parent folder because the Security properties of the folder I was trying to delete were blank, using CMD and Dir /x etc. I even tried sharing the parent folder and then using Server 2008 R2. None of them worked. When I tried Dir /x Server 2012 doesn't show the 8 character filename with the ~1. I tried typing it in myself, but that didn't work either. I then found that there was a space at the end of the folder name. I then tried all the CMD options again using a space, still no luck. Then I finally stumbled upon this solution:
Open CMD and then type:
rd /s "\\?\D:\bad\folder\path "
example: rd /s "\\?\D:\Sharedata\folder1\folder2 " - note the space after folder2 as per the space in the folder name. Obviously D: is the drive that has the folder on it.