save text file contents into a temporary variable and echo it only if that text file is modified
Posted: 13 Jan 2021 21:14
Currently what I have checks to see if a text file has been modified, if it hasn't then recheck else type out the file contents.
What im attempting to do is after the file contents have been tyuped out, store a temporary variable with the contents from that file and echo it ONLY when the file is modified. How do i achieve this?
heres my code
What im attempting to do is after the file contents have been tyuped out, store a temporary variable with the contents from that file and echo it ONLY when the file is modified. How do i achieve this?
heres my code
Code: Select all
@ECHO OFF &setlocal
color 2
set currentDate=%date%
SET File=run.txt
:check
FOR %%f IN (%File%) DO SET filedatetime=%%~tf
IF %filedatetime:~0, 10% == %currentDate% goto same
goto notsame
:same
goto next
:notsame
type %File%
for /f "tokens=*" %%A in (%File%) do (echo %%A)
:next
TIMEOUT /T 1 >nul
goto check
echo.
pause