How about going simple? No fancy MD5, just the output of the dir
command! This works because the dir command output will be exactly the same no matter when it is run if nothing has changed in the directory it is checking.
For Help and More Options see:
dir /?
fc /?
Example:
@echo off
if not exist old_fingerprint.txt echo. > old_fingerprint.txt
:: List the directory information, recursive, last write timestamps, 4 digit date
dir /n /s /t:w /4 > new_fingerprint.txt
:: Check out fc /? for all of the comparison options.
fc new_fingerprint.txt old_fingerprint.txt
:: fc sets errorlevel to 0 when the files match and not 0 when the files do not match.
if %ErrorLevel% NEQ 0 echo.No results found in 24 hours>> log.txt
If you want to hide all the output of the batch script just throw in a > nul
behind the fc
line.
Update: In light of the new information provided.
So you just need to check the last write time stamp of the Results.txt file. As long as you do not write to the file when there has been no changes and update the time stamp.
Or even better yet, if all you care about is whether or not a folder has had any activity inside of it, just check that folder's 'last write' time stamp. If the time stamp is older than 24 hours you can process your no results found in 24 hours.
Use the /t:w
option with the dir
command and you can parse the time stamp that you need.
TLDR: KISS
Update 2:
Here is an example script showing how to get a pure breakdown of the directory information.
@echo off
setlocal
for /f "usebackq tokens=1,2,3,4,*" %%A in (`dir /a:d /l /n /t:w /4`) do (
echo.
echo.Date = %%A
for /f "usebackq tokens=1,2,3 delims=/" %%X in ('%%A') do (
echo.Month = %%X
echo.Day = %%Y
echo.Year = %%Z
)
echo.Time = %%B
for /f "usebackq tokens=1,2 delims=:" %%X in ('%%B') do (
echo.Hour = %%X
echo.Minute = %%Y
)
echo.Meridiem = %%C
echo.Type Raw = %%D
for /f "usebackq tokens=1 delims=<>" %%X in ('%%D') do (
echo.Type = %%X
)
echo.Name = %%E
echo.
)
endlocal
Answer: Here is a script illustrating an easy way to get and compare the time stamps. Setup a scheduled task to run this script every 24 hours and if the time stamp has not changed since the last run, it will print out a message to the log file.
setlocal enabledelayedexpansion
for /f "usebackq tokens=1,2,3,4,*" %%A in (`dir /a:d /l /n /t:w /4`) do (
if /i "%%~E"=="Folder" (
if exist "LastTimeStamp.txt" find /c /i "%%A %%B %%C %%E" LastTimeStamp.txt > nul
if !ErrorLevel! EQU 0 echo.The folder time stamp has not changed since last checked. >> log.txt
echo.%%A %%B %%C %%E > LastTimeStamp.txt
)
)
endlocal