Batch to check if a single file is modified

[Solved/Closed]
Report
-
 todd -
HI, I'm not a programmer but I have to check in an external directory if a single file (myfile.avi) is modified or created today and if the answer is yes start another batch or quit.

I've found this code but does not work on my Win XP.
My date is DD/MM/YYYY.

@echo off
for %%F in (C:\TEST\myfile.avi) do (for /F %%D in ("%%~tF") do (set mdate=%%D)) for /F "tokens=2" %%D in ('date/t') do set cdate=%%D

if "%cdate%"=="%mdate%" start myprogram.bat



I hope someone can help me. Thank you in advance.

1 reply

This solution works on my Win XP Home Edition where the date format is: "DD/MM/YYYY"

@echo off 
for %%F in (C:\TEST\myfile.avi) do (for /F %%D in ("%%~tF") do (set mdate=%%D)) 
for /F "tokens=1" %%D in ('date/t') do set cdate=%%D
echo cdate="%cdate%"  mdate="%mdate%" current dir=%cd%
if "%cdate%"=="%mdate%" start myprogram.bat