Trying to write vbs script that searches directories to detect file modification
Posted on 2015-01-15
I'm trying to write a vbs script that searches a directory that has a new folder created each day with the day's date in the name then determine if certain files within this folder's subdirectories have been updated within 60 min. I need the results of the test to be written to a log for each file being tested. I've created a script to detect file change within 60 min but I'm having trouble creating logic in the script to look for a new directory as the date changes. An example of the directory structure being tested is below.
Below is the code I've written so far. It searches the entire C:/Syslogd/Logs/2015-01-12/device/ directory so is not taking date name change into account plus I'd like to be more precise with the file search (name specific file).
Dim fso, folder, files
Set fso = CreateObject("Scripting.FileSystemObject")
strPath = "C:/Syslogd/Logs/2015-01-12/Device/"
set folder = fso.GetFolder(strPath)
set files = folder.Files
CounterNum = 0
For each item in files
If DateDiff("N",item.DateLastModified,Now()) > 60 Then
FileUpdateStatus = "File has not been updated in the last hour"