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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete archive files older than a particular date.

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
0
0
US
Hi.
i am trying to write a script that scheduled to run every week and delete old archive files. the files are in a folder under c:\arch\.
i have a vbscript that examines the modify date of the file. but i need to look through all the files in that folder and delete anything that is older than 30 days old. any ideas?
thanks.
 
What's your script so far?
Basically all you should have to do is wrap it in a loop like this:
Code:
Dim fso, fol, f
[green]'set your File System Objects
'yadda'[/green]
For Each f in fol.Files
  [green]'do your magic[/green]
Next f

Cheers,
MakeItSo

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
For the date comparison, use the DateDiff function. Something like:
Code:
If DateDiff("d", f.DateLastModified, Date()) > 30 then
   'delete the file
End If
 
thank you both.
that helped :)
got it working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top