0
Thanks

A few words of thanks would be greatly appreciated.

Batch to check if a single file is modified


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
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
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).

0 Comments