Trying to put a batch file together that will find a string within a text file. Only obstacle is I want to find values that occur in the evening(PM) and NOT in the Morning(AM).
I am trying to find "XBR Upload successful" however only if exists in the PM:
Exert from the log file: [3:35:07AM] XBR Upload successful.
I have the following:
@echo off
findstr /M "[*PM] XBR Upload successful." C:\Test.log
if errorlevel = 1 GOTO NOMATCH
if errorlevel = 2 GOTO MATCH
Wildcards * does not seem to be working for me. Seems to find [*PM] even though in the log file no PM timing exists yet.
Any guidance appreciated!
You should try like that :
@echo off
Set InputFile=c:\Test.log
Set OutPutFile=c:\LogFile.txt
Type "%InPutFile%" |findstr /M /R /C:"\[.*PM\] XBR Upload successful." > %OutPutFile%
If "%Errorlevel%" EQU "1" GOTO :NOMATCH
If "%Errorlevel%" EQU "0" GOTO :MATCH
:MATCH
Color 0A
echo MATCH
pause
Start "" %OutPutFile%
Exit /b
:NOMATCH
Color 0C
echo NO MATCH
pause
Exit /b