>Can a script be created to delete files older than "x" amount of days, not
>just past a particular date but calculate the age of a file and delete them
>once they reach, perhaps, 31 days? If so, any guidance would be appreciated.
Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("J:\aaaa")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 31 Then
f1.Delete
End If
Next
Set fso = Nothing
Set f = Nothing
Set fc = Nothing
--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
to tell you the truth, the code was taken from an old post in another newsgroup. ;-)
Giovanni.
>Excellent script. A good example of 'to-the-point' code that gets the job
>done. Thanks for sharing.
I have tons of these scripts.
All copied from other newsgroups and web sites. ;-)
fileExt = fso.GetExtensionName(f1.Path)
If fileExt = "doc" Or fileExt = "ldf" Then
If DateDiff("d", f1.DateLastModified, Now) > 31 Then
f1.Delete
End If
End If
I never tried.
You could try to put this into a sub and if the directory entry is a subdir, then call the
sub recoursively.
Maybe it's easier to shell a DIR /S/B >LIST.TXT
and check every entry of the txt file.
How i can delete a files older than a 30 days with filename*.extension
(f*.txt)....
Can anyone help