Re: Script to delete files
- From: "James Whitlow" <jwhitlow@xxxxxxxxxx>
- Date: Thu, 14 Jul 2005 13:05:25 -0500
"dude" <secrect@xxxxxxxx> wrote in message
news:OYjx6WIiFHA.3540@xxxxxxxxxxxxxxxxxxxxxxx
> Im trying to make a simple script, that can delete some files older than
30
> days,
> but im not soure where to start.
> I hope someone can help me using the filesystemobject.
I use just such a script. I have some log files that I have to keep for a
week.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = FSO.GetFolder("D:\Resource\Data\logs")
For Each File in oFolder.Files
If DateDiff("d", CDate(File.DateLastModified), Now()) > 7 Then
FSO.DeleteFile File
Next
Set oFolder = Nothing
Set FSO = Nothing
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I schedule it to run every day using the AT scheduler:
AT 05:00 /INTERACTIVE /EVERY:S,M,T,W,Th,F,Sa "R:\Delete Files"
Just customize the path & DateDiff in the above script to meet your needs.
Consider that the script as it is currently written affects all files in the
given directory.
.
- References:
- Script to delete files
- From: dude
- Script to delete files
- Prev by Date: Re: DHCP and VBScripting
- Next by Date: Re: addwindowsprinterconnection fails
- Previous by thread: Re: Script to delete files
- Next by thread: Re: Script to delete files
- Index(es):
Relevant Pages
|