title: VBScript - Notification when file not created today
body: <p>Goal: To run a VBScript that checks a folder daily, and reports if no files were saved to it that day. Ignore the files that exist from previous days.</p>
  
  <p>Scenario: A logfile is created everyday in C:\Temp at 3am. This is what tells us that the system performed a task. If a log file isn't generated, then the task crashed. I wrote this to check the Temp folder for a file created today, and to email me if it doesn't exist. </p>
  
  <p>Solution thus far: </p>
  
  <pre><code>option explicit 
  dim fileSystem, folder, file 
  dim path  
  path = "C:\Temp" 
  
  Set fileSystem = CreateObject("Scripting.FileSystemObject") 
  Set folder = fileSystem.GetFolder(path) 
  
  for each file in folder.Files     
    if file.DateLastModified &gt; dateadd("h", -24, Now) then 
  'WScript.Echo file.Name &amp; " last modified at " &amp; file.DateLastModified 
  else 
  SendEmail
  'WScript.Echo "this should have sent an email."
    end if 
  next 
  
  Function SendEmail() 
   'Send Email notification function here (this part works already)
  End Function
  </code></pre>
  
  <p>Issue I am having: </p>
  
  <p>I can't seem to wrap my head around a way to have the script ignore files in the folder from previous days. </p>
  
  <p>In my test, I have C:\Temp populuated with a file modified today, and a file modified on 7/10/12. Because this scenario matches both the 'then' and the 'else' statement, it's doing both. </p>
  
  <p>I think I just need a slight modification on the loop to tell it 
  - Ignore files not dated 'today' 
  - Send an email if no files exist today. </p>
  
  <p>Any help would be awesome. I just can't seem to 'see' the answer. </p>