Hi Again Group,

I have the following code which deletes all file over 7 days old.

sDateTime = Year(dDate) & Right(100 + Month(dDate),2) _
& Right(100 + Day(dDate),2) & "_" & Right(100 + Hour(dDate),2) _
& Right(100 + Minute(dDate),2) & Right(100 + Second(dDate),2)
sFilename = sDateTime & ".zip"

'Delete OLD Data - This Keeps 7 Days worth of Backups
Set Folder = FSO.GetFolder("C:\zips\DataBackup\HFSdata")
For Each File in Folder.Files
If DateDiff("d", CDate(File.DateLastModified), Now()) > 7 Then
FSO.DeleteFile File
Next

What I would like to be able to do is if the file is Less than 24 Hours old
copy the Data to a Zip Disk on Drive Z:

I guess I would Add in something like:
If DateDiff("d", CDate(File.DateLastModified), Now()) > 7 Then FSO.CopyFile
File?? but I can`t find any info on the net tho:( Anybody kindly give me
some code or point me in the right direction?

Many Thanks
Regards
NSC

Re: Another Question:( by James

James
Wed Nov 30 10:54:19 CST 2005

"NOT_SO_CLEVER" <test@test.com> wrote in message
news:e5GM1na9FHA.1224@TK2MSFTNGP12.phx.gbl...
> Hi Again Group,
>
> I have the following code which deletes all file over 7 days old.
>
> sDateTime = Year(dDate) & Right(100 + Month(dDate),2) _
> & Right(100 + Day(dDate),2) & "_" & Right(100 + Hour(dDate),2) _
> & Right(100 + Minute(dDate),2) & Right(100 + Second(dDate),2)
> sFilename = sDateTime & ".zip"
>
> 'Delete OLD Data - This Keeps 7 Days worth of Backups
> Set Folder = FSO.GetFolder("C:\zips\DataBackup\HFSdata")
> For Each File in Folder.Files
> If DateDiff("d", CDate(File.DateLastModified), Now()) > 7 Then
> FSO.DeleteFile File
> Next
>
> What I would like to be able to do is if the file is Less than 24 Hours
old
> copy the Data to a Zip Disk on Drive Z:
>
> I guess I would Add in something like:
> If DateDiff("d", CDate(File.DateLastModified), Now()) > 7 Then
FSO.CopyFile
> File?? but I can`t find any info on the net tho:( Anybody kindly give me
> some code or point me in the right direction?

You can read about 'CopyFile' here:
http://msdn.microsoft.com/library/en-us/script56/html/jsmthcopyfile.asp
You can read about 'DateDiff' here:
http://msdn.microsoft.com/library/en-us/script56/html/vsfctdatediff.asp

You could put something like this just about your 'Next' line:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If DateDiff("h", CDate(File.DateLastModified), Now()) < 24 Then
FSO.CopyFile File, "Z:\", True
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Considering that the 'File.DateLastModified' and 'Now()' are already of
the date subtype, you don't need to convert them to them the data subtype
using 'CDate'. It certainly does not hurt anything, but you don't need to do
it. You could change the first line of the code about to look like this:

If DateDiff("h", File.DateLastModified, Now()) < 24 Then