|I've SEARCHED EVERYWHERE I can't find a solution. Basically I have a group of text files that contain serial numbers of switches I own. The batch file I made looks for the keyword "SN" and writes the file name along with the result in a text file called Results.txt. However I have a few text documents that have multiple instances of the word "SN" and the batch file only returns the last result found in the text files. Here is my code|
for /f "delims=" %%f in ('dir /s/b/a-d *.txt') do call :p "%%f"
for /f "delims=" %%a in ('findstr /c:"SN" %1') do set "SN=%%a"
echo %~n1 %sn% >> .\Results.txt
Here is a example file it's searching (192.168.1.1.txt)
NAME: "1", DESCR: "WS-C3750-48TS"
PID: WS-C3750-48TS-S , VID: V05 , SN: xxxxxxxxxx
NAME: "GigabitEthernet1/0/1", DESCR: "1000BaseLX SFP"
PID: , VID: , SN: xxxxxxxxxx
NAME: "2", DESCR: "WS-C3750-48P"
PID: WS-C3750-48PS-S , VID: V06 , SN: xxxxxxxxxx
NAME: "3", DESCR: "WS-C3750-48P"
PID: WS-C3750-48PS-S , VID: V05 , SN: xxxxxxxxxx
NAME: "4", DESCR: "WS-C3750G-48PS"
PID: WS-C3750G-48PS-S , VID: V06 , SN: xxxxxxxxxx
And here is the result I get from Results.txt
192.168.1.1 PID: WS-C3750G-48PS-S , VID: V06 , SN: xxxxxxxxxx
As you can see it only returns the LAST result (NAME:"4") in Results.txt for some reason. Please help me. Thank you