Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Wed, 11 Jun 2008 09:40:01 -0700,    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


deleting files older than * days   
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.
date: Wed, 11 Jun 2008 09:40:01 -0700   author:   MonkeytownGuru

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

Re: deleting files older than * days   
Il giorno Wed, 18 Jun 2008 07:36:00 -0700, =?Utf-8?B?TW9ua2V5dG93bkd1cnU=?=
 ha scritto:
>Reventlov: So simple but so effective - Much appreciated

to tell you the truth, the code was taken from an old post in another newsgroup. ;-)
Giovanni.


-- 
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 22:00:54 GMT   author:   (Reventlov)

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us