Batch to check if a single file is modified

December 2016


Batch to check if a single file is modified




Issue


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 it 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.

Solution


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

Note


Solved by todd

Related :

This document entitled « Batch to check if a single file is modified » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.