Technology

Removing empty files and folders in Windows 8.1 using the command line

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 8.1 right click on the Windows Button bottom left corner and select Command Prompt (Admin)

2.  Make an empty directory by typing the following command – mkdir C:\EmptyDir

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 last command – rmdir C:\Undeletable /S /Q

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

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.

Advertisements

2 replies »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s