Batch to check if a single file is modified

July 2017


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


Published by aakai1056. Latest update on August 2, 2010 at 08:18 AM by aakai1056.
This document, titled "Batch to check if a single file is modified," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).