Hi All,

Wonder if somebody could kindly help me? Im fairly new to this so please
excuse me if I sound daft.

I have a VBS script that copies a file from 1 Directory to Aanother each
night. The file is Approx 290megs and grows about 2meg per day. Currently
all is working well however im deleting the previous weeks files manual each
monday. (Its a backup, and we need seven days worth) as they are starting to
take up a fair amount of space. Is there a way to get the VBS script to
check the earlist file and delete it if it is over a week old?

Any Help much appriciated
Many Thanks
Regards
Si

Re: Is this to Complicated? by Torgeir

Torgeir
Fri Jun 24 06:41:46 CDT 2005

Wizard wrote:

> Hi All,
>
> Wonder if somebody could kindly help me? Im fairly new to this so please
> excuse me if I sound daft.
>
> I have a VBS script that copies a file from 1 Directory to Aanother each
> night. The file is Approx 290megs and grows about 2meg per day. Currently
> all is working well however im deleting the previous weeks files manual each
> monday. (Its a backup, and we need seven days worth) as they are starting to
> take up a fair amount of space. Is there a way to get the VBS script to
> check the earlist file and delete it if it is over a week old?
Hi,

A start point maybe:

In the article below there is a WSH script (vbscript) by Michael Harris
that deletes files that has not been modified in x days old in a
specific folder (and optionally all subfolders).

Newsgroups: microsoft.public.scripting.wsh
Date: 2002-10-07 08:12:33 PST
http://groups.google.co.uk/group/microsoft.public.scripting.wsh/msg/14df6623fc552446?dmode=source

For a version that filters on a specified file extension as well:
http://groups.google.co.uk/group/microsoft.public.scripting.vbscript/msg/5b442f482bab6c03?dmode=source&hl=en



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Is this to Complicated? by James

James
Fri Jun 24 07:54:07 CDT 2005

"Wizard" <test@test.com> wrote in message
news:92-dnQDOL9QabCbfSa8jmw@karoo.co.uk...
> Hi All,
>
> Wonder if somebody could kindly help me? Im fairly new to this so please
> excuse me if I sound daft.
>
> I have a VBS script that copies a file from 1 Directory to Aanother each
> night. The file is Approx 290megs and grows about 2meg per day. Currently
> all is working well however im deleting the previous weeks files manual
each
> monday. (Its a backup, and we need seven days worth) as they are starting
to
> take up a fair amount of space. Is there a way to get the VBS script to
> check the earlist file and delete it if it is over a week old?

I actually do something very similar to this. I have some huge logs files
that are written daily. I am required to keep seven days worth of them, but
no more. I use a VBScript file to look at the dates of the files and delete
the files older than 7 days. I use an AT schedule to fire the script each
morning at 5 am.

--------------------BEGIN Delete old logs.vbs--------------------
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("c:\logs")
For Each File in Folder.Files
If DateDiff("d", CDate(File.DateLastModified), Now()) > 7 Then
FSO.DeleteFile File
Next
Set Folder = Nothing
Set FSO = Nothing
-------------------------------END-------------------------------

This what I typed to generate my AT schedule:

at 05:00 /INTERACTIVE /EVERY:M,T,W,Th,F,S,Su "C:\Delete old logs.vbs"

Mine runs every day of the week. Since you only want it to run on Monday,
just remove the other days out of the AT command.