|
|
|
date: Wed, 11 Jun 2008 09:40:01 -0700,
group: microsoft.public.inetsdk.programming.scripting.vbscript
back
Re: deleting files older than * days
Il giorno Wed, 11 Jun 2008 09:40:01 -0700, =?Utf-8?B?TW9ua2V5dG93bkd1cnU=?=
ha scritto:
>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)
--
date: Wed, 11 Jun 2008 21:21:04 GMT
author: (Reventlov)
Re: deleting files older than * days
Reventlov: So simple but so effective - Much appreciated
"Reventlov" wrote:
> Il giorno Wed, 11 Jun 2008 09:40:01 -0700, =?Utf-8?B?TW9ua2V5dG93bkd1cnU=?=
> ha scritto:
>
> >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)
> --
>
date: Wed, 18 Jun 2008 07:36:00 -0700
author: MonkeytownGuru
|
|