UPDATE: This was originally posted by Grocs on January 6 2015 and was originally related to Windows 8.1 issues but it can also be applied to Windows 10 with a slight tweak to the commands. It’s still a VERY helpful tip to know and one I found useful again! 🙂
So while I’m on holidays I’ve been doing a little spring cleaning on my computer and noticed there was a folder with a bunch of sub-folders and files that have zero bytes associated with them. After trying numerous things I did some searching and found via Tom’s Hardware forums (thanks DarkSideMilk –http://www.tomshardware.com/forum/4256-73-delete-files-folders-owner-admin) a very handy tip that allowed me to remove this folder structure, including all sub-folders and files relatively easily.
The steps are (where Undeletable is the folder you can’t remove):
1. Open a command prompt as administrator (in Windows you’ll either see an option to “run as Administrator” or can right click on the icon and choose to do so.
2. Make an empty directory by typing the following command:
mkdir C:\EmptyDir (for Windows 8.1), or
md C:\EmptyDir (for Windows 10)
3. Use Robocopy to copy this empty directory to your undeletable folder by typing this:
robocopy C:\EmptyDir C:\Undeletable /s /mir
4. Now you can safely remove the offending folder that you haven’t been able to remove. To do this type the command
rmdir C:\Undeletable /S /Q (for Windows 8.1), or
rd C:\Undeletable /S /Q (for Windows 10)
5. Repeat the process for any other folders or files you need to delete then delete the empty directory with steps 2 through to 4.
6. Finally remove the empty directory you created in step 2
rmdir C:\EmptyDir (for Windows 8.1), or
rd C:\EmptyDir (for Windows 10)
This got me out of trouble when I was cleaning up a folder that just wouldn’t go away.
Please be careful with this. If you are not comfortable working with DOS type commands I would ask a friend to help.