Inform the User when a specific file updates or changes (SOLVED)

Posted on


The other day I tried to make a batch file that will tell the user the Contest of a file when
a specific text file updates/changes here’s my code so far it doesn’t work for some reason :S

    @echo off
SetLocal EnableDelayedExpansion
ping -n 2 -w 1000 > NUL
ping -n %1 -w 1000 > NUL
set test=
for /F "delims=" %%a in (test.txt) do set test=!test! %%a
if !test!==%VAR% ( 
goto Try
) else ( 
echo !test!
set VAR1=!test!
goto Try

This is what I’m trying to do..

Wait 2 seconds.
clear the screen.
turn the content of test.txt to a variable.
compare the variable with the other variable called %VAR%.
since there’s no variable to compare with in the beginning it goes to else statement and will output the content once.
Then it will make the current content to a variable.
It will go back to the beginning and try again.. If the test.txt have changed it will go to else once again. If not it will go back to try and wait for the file to change.

Please help me out it’s very annoying.


So today I was messing around with the code and started to try other methods because I doubt this method would work.. So I thought “Out Side Of The Box”. In my case I have a batch file that changes this text document called test.txt every now and then.. So I changed that one. This is the label

set /p inp=
echo %date% %inp% > test.txt
echo 0 >> tmp.yml"
goto Start

And I rewrote the other batch too..

@echo off
color 04
set /p texte=< test.txt  
if exist "tmp.yml" goto Changed
goto Try
del "tmp.yml"
echo %texte%
goto Try

Hope someone found this useful 😀


I would suggest not re-inventing the wheel and use an application that is well defined and designed for such a purpose.

Tail for Windows

Tail for Windows looks nice, but following @dmcgill50 recommendation I just try it and not work for me (tried with a file in Dropbox, Win8 x64).
Would be nice to know one way to do this.

Maybe one of the recomendations in this page can help you:

10 Tools to Monitor Files and Folders for Changes in Real Time

Leave a Reply

Your email address will not be published.