Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting large amount of files

Status
Not open for further replies.

JamesLean

Programmer
Dec 13, 2002
3,059
GB
I have a folder on a Windows 2003 SP2 server which has a large amount of files in it, probably a couple of hundred thousand, going back over a few years. I am trying to delete all the old files and just keep one month's worth.

If I try and just open the folder in explorer it just hangs. Does anyone have any tips on the best way to go about deleting these files? I need to do an initial delete to get a month's worth and then set up a scheduled task to retain that amount.

I am not sure whether some kind of DOS batch file would work or whether it is something I would need to do using VBScript or similar?

--James
 
The reason why it's hanging is because it takes awhile to enumerate 100,000+ files using Explorer (eventually it will respond). You can easily use the command line to view/delete the files.

For example if you wish to delete all files with the extension *.log from all your subdirectories you can type

DEL /S *.LOG

Hope this helps
 
Sorry, the key point of the question was that I only want to delete files older than 1 month. AFAIK the del command can't filter by date.

I was wondering whether anyone had a batch file or other script that could do this?

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top