I'm trying to write some code (in batch/powershell) that will launch a batch script that I've made (with the help of some great people here) when a change is detected in a logfile, I've tried some solutions, such as this one, but it wouldn't correctly detect when the file was modified, which I believe to be due it being open in the program that is logging to it. I found this
Get-content filename -Tail 0 -Wait
powershell command that would correctly display any new changes added to the file, but I'm not sure if I can use that to launch my other script. Here is that script if it helps
@echo off
copy foobar.log file.log /Y > NUL
echo Loading...>currentsong.txt
timeout /t 5 /nobreak > NUL
setlocal enabledelayedexpansion
for /f tokens^=2^ delims^=^" %%a in (file.log) do (
set "lastLine=%%~na"
)
echo %lastLine%>currentsong.txt
endlocal
Any help is greatly appreciated. Thanks!