Hi,
I have a batch file which searches through a text file for keywords for errors. It uses FINDSTR to do this and then it outputs the problem lines to another text file...
Here's the bat file..
findstr /i /n /g:"c:\Users\statrox\WINLC\KEYS_IN1.TXT" "%~DPN1.LOG" >> "C:\Users\statrox\WINLC\%~n1.tmp"
findstr /i /r /v /g:"c:\Users\statrox\WINLC\KEYS_OUT1.TXT" "C:\Users\statrox\WINLC\%~n1.tmp"
del "C:\Users\statrox\WINLC\%~n1.*"
Here's an example of the output.... for the lines beginning with xxxx: I need the name of the file appended in front of each line.. so the lines should look like the following....
F:\2011-001\STATIS~1\Pubs\WM_201~1\Work\VALIDA~1\Programs\vtdemog4.LOG:1114:WARNING 1-322: Assuming the symbol TRANSPOSE was misspelled as transpoze.
instead of looking like this...
1114:WARNING 1-322: Assuming the symbol TRANSPOSE was misspelled as transpoze.
1407:WARNING 1-322: Assuming the symbol TRANSPOSE was misspelled as transpoze.
1700:WARNING 1-322: Assuming the symbol TRANSPOSE was misspelled as transpoze.
1993:WARNING 1-322: Assuming the symbol TRANSPOSE was misspelled as transpoze.
2284:WARNING 1-322: Assuming the symbol TRANSPOSE was misspelled as transpoze.
2579:WARNING 1-322: Assuming the symbol TRANSPOSE was misspelled as transpoze.
F:\2011-001\STATIS~1\Pubs\WM_201~1\Work\VALIDA~1\Programs>del "C:\Users\statrox\WINLC\vtdemog4.*"
Appending the filename to the beginning of each line
Moderator: DosItHelp
Re: Appending the filename to the beginning of each line
The easy way is to add /s to your findstr command, if that is enough for you.