View Single Post
  #1 (permalink)  
Old August 5th, 2009, 05:14 PM
abbiejoy21 abbiejoy21 is offline
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Search for files modified within the last five minutes

I'm completely new to programming and scripting. I need a script that searches a folder for a file named *_single.xml and a file named *_full.xml. It must find at least one of each that has been modified within the last five minutes. If either one of these files does not exist with a last modified date of within five minutes, the script will fire a windows event. The script I have right now checks a specific file to see if it has been checked within five minutes, but now I need the script to search the folder for those two files and check the date modified on all results. Here's my current script. Thanks in advance for any help!

--------------------------------------------------------------------------
Option Explicit

'* DEFINE CONSTANTS
Const EVENT_ERROR = 1
Const EVENT_INFORMATIONAL = 4

'* DECLARE VARIABLES

Dim objShell, objExecObject, strText
Dim FSO,File
Dim Date1,Date2,Hour1,Hour2

'* Set environment and open output file

Set objShell = WScript.CreateObject("WScript.Shell")
set FSO=CreateObject("Scripting.FileSystemObject")
Set File=FSO.GetFile("c:\test\test.txt")

Date1=Now()
Date2=File.DateLastModified
'wscript.echo DateDiff("s",Date2,Date1),"Seconds"

If DateDiff("s",Date2,Date1) > 300 then
objShell.LogEvent EVENT_ERROR, "file has not been written to within the last 5 minutes"
End if
Reply With Quote