?
Solved

Delete a huge folder in Windows help

Posted on 2009-12-17
10
Medium Priority
?
617 Views
Last Modified: 2013-12-06
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.
0
Comment
Question by:mattkovo
9 Comments
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 26072589
Have you tried running the del command from the command line?

http://tmdnet.nothave.com/book/OS/MANUALS/COMMANDS/D/DEL.HTM
0
 

Author Comment

by:mattkovo
ID: 26072872
xxdcmast.  That's the first thing I tried.  It just hangs up and doesn't do anything.
0
 
LVL 16

Expert Comment

by:warturtle
ID: 26075952
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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
LVL 3

Expert Comment

by:Jlucht
ID: 26081565
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
 
LVL 15

Expert Comment

by:greyknight17
ID: 26082785
You can give Mass Directory Eraser a try to see if it can do the job quickly.
0
 

Author Comment

by:mattkovo
ID: 26107087
I'll try they greyknight17.  Non of the other solutions are working yet.
0
 

Author Comment

by:mattkovo
ID: 27658984
Still not working.
0
 
LVL 1

Accepted Solution

by:
peter_v1969 earned 2000 total points
ID: 27659199
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
 

Author Comment

by:mattkovo
ID: 29217374
hahaa.  Thanks for the help.  I will give it a shot!
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question