Delete a huge folder in Windows help

I created a smtp server in IIS and before I set the security on it I had some spammers trying to use it.  Now I have around 3.5 million files in 1 folder that I need to delete.  I've tried shift delete and  command prompt.  I was able to rename the folder no problem but can seem to delete the files all at once.  Any ideas how I can delete them?

I'm running Windows Server 2008.
mattkovoAsked:
Who is Participating?
 
peter_v1969Connect With a Mentor Commented:
3.5M entries in your directory will take a LONG time irrespective of your method to delete them, save reformatting your hard drive, and it will appear to hang whatever session you attempt to use to delete the records.  The trick is to ensure that you load the delete command into a session that doesn't blow up your CPU or windows threads.  I literally would expect that to take hours, if not a day or three.

If you can afford the downtime, run a comprehensive defragment on your server firtst - that many directory entries will have scattered the directory listing.  I would expect this to dramatically affect the performance of a delete command here.

1. open up the command line, go to the directory above the log directory and at the command line type "rmdir logs /s" and go on holiday.  At least this shouldn't interrupt the rest of your server processes.

The only issue here will be if any of the files are currently open, this command won't complete.  If you need this directory to be live while you operate the server, then temporarily take the server process that's locking the directory offline, rename the directory, re-create it empty, and re-enable the server process, then delete the renamed directory as per above.  I've never renamed a directory with that many files in it, but I do think it'll be instant - or at most take a few minutes.

If no files are open and the command does return, you should recreate the logs directory.

2. Create a script file that manually deletes each file, kick that off and go home for a few days.....  it'll take a long time to finish executing, however it'll delete each unlocked file and shouldn't hang your server.  You'll need to download a fancy text editor to do this, and I'd recommend gvim (www.vim.org).    

steps to do this:  (You'll need plenty of spare RAM and some patience)
  1. at the command line change into the directory that has the log files
  2. assuming you have a c:\temp directory (if not, create one) type at the command line:
        DIR /b > C:\temp\delbatch.bat
  3. Open up the file in GVIM.  Gvim is keystroke sensitive, so if you aren't familiar with it, follow the keystrokes exactly.
  4. Using gvim hit the following keystrokes (without the quotes)
          ":1,$s/^/del "
      *note: ensure there is a space after the "del"
      This will create a batch file that deletes each file individually, and won't crash if one file is locked for any reason.
       To save a file, just hit ZZ  (capital letters)
   5.  from the command line in the log directory, run the batch file:
       \temp\delbatch
   6. Go watch the Lord of the Rings trilogy - directors cut.
0
 
Joseph DalyCommented:
Have you tried running the del command from the command line?

http://tmdnet.nothave.com/book/OS/MANUALS/COMMANDS/D/DEL.HTM
0
 
mattkovoAuthor Commented:
xxdcmast.  That's the first thing I tried.  It just hangs up and doesn't do anything.
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
warturtleCommented:
Hello,

Unlocker might be helpful in this situation.

http://download.cnet.com/Unlocker/3000-2248_4-10493998.html

After installing it, right click on folder and select 'Unlocker'.

Try it.
0
 
JluchtCommented:
The files should incremental names right?  Log1234567890.log

have you tried to do a

"Del c:\logfolder\Log123456*.log"

Then do a

Del c:\logfolder\Log1234*.log
0
 
greyknight17Commented:
You can give Mass Directory Eraser a try to see if it can do the job quickly.
0
 
mattkovoAuthor Commented:
I'll try they greyknight17.  Non of the other solutions are working yet.
0
 
mattkovoAuthor Commented:
Still not working.
0
 
mattkovoAuthor Commented:
hahaa.  Thanks for the help.  I will give it a shot!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.