RE: delete files in a folder that are certain days old
- From: ESP <ESP@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 8 Nov 2005 13:40:15 -0800
Exactly. Using the "NOW" command will specify today's date/time/etc..., this
will happen.
ESP
"WILDPACKET" wrote:
> This article talks about deleting oldar than specified date.
>
> In my scenario I want to schedule the files to be deleted which are older
> than 2 days using a similar script.
>
>
>
>
>
>
>
>
> ESP" wrote:
>
> > The Scripting Guys have a nice lil' page on this. Very easy to follow :-)
> >
> > http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1104.mspx
> >
> >
> > ESP
> >
> >
> >
> >
> >
> > "WILDPACKET" wrote:
> >
> > > I am nill with scripting. I found this script on the net and I would like to
> > > delete files older than 2 days from a folder. Please correct this for me. I
> > > really appreciate.
> > >
> > > Option Explicit
> > > on error resume next
> > > Dim oFSO
> > > Dim sDirectoryPath
> > > Dim oFolder
> > > Dim oFileCollection
> > > Dim oFile
> > > Dim iDaysOld
> > >
> > > 'Customize values here to fit your needs
> > > iDaysOld = 2
> > > Set oFSO = CreateObject("Scripting.FileSystemObject")
> > > sDirectoryPath = "FolderName here. Can be UNC path like \\MyServer\MyFolder"
> > > set oFolder = oFSO.GetFolder(sDirectoryPath)
> > > set oFileCollection = oFolder.Files
> > >
> > > 'Walk through each file in this folder collection.
> > > 'If it is older than 3 weeks (21) days, then delete it.
> > > For each oFile in oFileCollection
> > > If oFile.DateLastModified < (Date() - iDaysOld) Then
> > > oFile.Delete(True)
> > > End If
> > > Next
> > >
> > > 'Clean up
> > > Set oFSO = Nothing
> > > Set oFolder = Nothing
> > > Set oFileCollection = Nothing
> > > Set oFile = Nothing
> > >
> > >
> > > Thank you very much in advance.
> > >
.
- References:
- RE: delete files in a folder that are certain days old
- From: WILDPACKET
- RE: delete files in a folder that are certain days old
- Prev by Date: can't compile
- Next by Date: Re: can't compile
- Previous by thread: RE: delete files in a folder that are certain days old
- Next by thread: Script to delay autologon
- Index(es):
Relevant Pages
|