View Single Post
  #4 (permalink)  
Old August 6th, 2009, 05:17 PM
Old Pedant Old Pedant is offline
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I was really afraid that was what you meant, but had to ask.

This is 100% UNTESTED, but if it's wrong it should be wrong in the details, not in the concepts.
Code:
Option Explicit

'* DEFINE CONSTANTS
Const EVENT_ERROR = 1
Const EVENT_INFORMATIONAL = 4
Const FULL = "_full.xml"
Const SINGLE = "_single.xml"


'* DECLARE VARIABLES
Dim objShell
Dim FSO, fldr, File
Dim fulllen, singlelen
fulllen = Len(FULL)
singlen = Len(SINGLE)

'* Set environment and open output file

' why do you create this until you need it?
Set objShell = WScript.CreateObject("WScript.Shell")

Set FSO = CreateObject("Scripting.FileSystemObject")
Set fldr = FSO.GetFolder("c:\test")

Dim matchfull, matchsingle
matchfull = False
matchsingle = False

For Each file In fldr.Files
    If Not matchfull Then
        If Right(LCase(file.Name),fullen) = FULL Then
            matchfull = ( DateDiff("s",File.DateLastModified,Now()) <= 300 )
        End If
    End If
    If Not matchsingle Then
        If Right(LCase(file.Name),singlelen) = SINGLE Then
            matchsingle = ( DateDiff("s",File.DateLastModified,Now()) <= 300 )
        End If
    End If
    If matchfull AND matchsingle Then Exit For ' no point in continuing
Next

If ( Not matchfull ) AND ( Not matchsingle )  Then
    objShell.LogEvent EVENT_ERROR, "One or both files have not been written to within the last 5 minutes"
End if

'
'
Reply With Quote