Hi Gurus, I'm trying to write a bat script which will loop through a text file & search multiple different type of messages and assign variable to each type of message. The txt file may content 3 types of messages: Success, Error, & Fails.
Here is the condition: I may have a success & error at the same time in the file. So, if it found both of them, then set the status==error. If it found only success, set status==success; otherwise, if it found fails, set status==fails.
for /f "token=*" %%a IN (C:\testfile.txt) DO (
'FINDSTR /i /m "successfully loaded/unloaded" C:\testfile.txt if exist set %status%==Success',
'FINDSTR /i /m "Error" AND "successfully loaded/unloaded" C:\testfile.txt if exist set %status%==Error',
'FINDSTR /i /m "Fails" C:\testfile.txt if exist "Fails" set %status%==Fails'
)Please helps.......
Thanks,
-Daigia
try this..
@echo off
SetLocal ENABLEDELAYEDEXPANSION
set status=Error
for /f "token=*" %%a in ('find /i /c "sucessfully"') do
if "%%a" GEQ "1" set !status!=Success
Endlocal
Thx for a response, but this only solves the problem w/ success & failure. I have a case that the job is successful but has some errors, Not a fails job. It just completed w/ errors and I'm trying to capture this scenario in the codes. Any helps/ideas are appreciated. Thanks.
-Daigia
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |