I have a runaway process or infestation that is creating files. It has created over 20 M files in one folder. Is there any way to delete this folder regardless of the number of files in it. The creating of files was halted by changing the name of the folder. System will not open folder due to number of files in it.

Edit by Ed DeUdell. April 2 2011 This seems to have deleted the folder.
Changed folder name which stopped it growing - At some time early on I tried to move the folder to the trash. That did not work. - ran CMD: ATTRIB -s -h -r -a Wait two days. Monday morning the folder was in the trash. Delete trash. Wait two days Wensday morning Trash is empty and I have 3.6 G of free space on my C drive.

That did it. Thank everyone who commented. You helped a lot regardless of your suggestions working for me.

  • 1
    slightly different question, but related in that I had to delete thousands of files.. millions is going to be excruciating! serverfault.com/questions/49614/delete-files-older-than-x-days – Jeff Atwood Mar 15 '11 at 5:24
  • The system will open the folder, you just have to be patient. Very patient. :) – John Gardeniers Mar 15 '11 at 6:52
  • That program to delete files older than x days seems to do a nice job of counting them. It finds exactly 8479860 files each time I run it regardless of # of days. – Ed DeUdell Mar 18 '11 at 1:14

I suggest you don't even try this from the GUI because that would cause Explorer to open each and every file to determine things like file type and icon. It will also cause your anti-virus software to scan all those files, even if only to determine whether or not they should be scanned.

I suggest you simply open a command prompt, either disable your AV software or tell it not to go anywhere near the folder in question and run del foldername/*. Then go away and do something else for as long as this takes to run.

Of course it would be a lot quicker to simply restore the entire system from backup.


If you feel like living a little dangerously you can download Nuke.com, which will delete those files even faster. Run it from the command prompt as nuke foldername. It won't work on a root folder (by design) but otherwise just gets on with the job without asking for confirmation, so be very sure of what you tell it to nuke. There's a possibility it might fail or even crash when used on really long path names because it was originally created for win95 and I've never updated it.

  • If the problem was not safely backed-up in the backup. GUI is not an option it takes at least 7 days to open the folder. Oh THANK you for any ideas. Seriously. Thanks – Ed DeUdell Mar 15 '11 at 7:03
  • @Tom, perhaps you should read my answer again. Especially the part where I specifically stated NOT to use the GUI. – John Gardeniers Mar 15 '11 at 7:05
  • Yes I was confirming that. I am not trying to do anything through GUI on this. – Ed DeUdell Mar 15 '11 at 7:06

del /s /f /q [folder] from a command prompt. It takes a while but eventually it will get the job done.

Disabling the viruscanner might speed it up a bit, but is maybe not possible for you.

Whatever you do: Don't use Explorer or a GUI file-manager. Just building the file-list for display purposes may cause an out-of-resources issue, crashing the server completely.

  • P.S. rmdir /s /q <folder> and del /s /q /f <folder> are functionally completely equivalent. – Tonny Mar 21 '11 at 16:44

Tried rd /s foldername ?

It might be more effective than deleting the individual files. Might.

  • Tried rd without the /s and did not do anything. I will try again and see. – Ed DeUdell Mar 18 '11 at 1:14
  • Use the /S . Without it, the directory won't be removed if there's anything in it. – TristanK Mar 18 '11 at 1:59

Perl is cross platform. This might help:


  • That will certainly work but will be a bit slower than doing a wildcard delete from the command line. – John Gardeniers Mar 21 '11 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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