CODE: [Copy to clipboard]
@echo off
set "Head=(echo ACTIVE ALARM INFORMATION FOR LOCATION !N!& echo.& echo Device Alarm Clear& echo ^(Subtype^) Code Type Tag^(hex^) Date/Time Description)"
setlocal EnableDelayedExpansion
for /f "delims=" %%F in ('findstr /m /c:"78 FMIC" /c:"243 FMIC" "*.txt"') do (
echo %%~nxF>>ACT.txt
for /f "tokens=1-6,*" %%1 in (%%~sF) do (
if "%%5"=="LOCATION" set "!N!=" 2>nul & set N=%%6
if defined 括号行 set "括号行=" & echo %%1 %%2 %%3 %%4>>ACT.txt
for %%a in (78 243) do (
if "%%5"=="%%a" (
if not defined !N! set "!N!=." & (if defined 空行 echo.>>ACT.txt)&%Head%>>ACT.txt
echo %%1 %%2 %%3 %%4 %%5 %%6 %%7>>ACT.txt
set "括号行=." & set "空行=."
)
)
)
echo.>>ACT.txt & set "空行="
)