I think I understand the problem. Given some line in the diflog.txt file with the contents of the Sumbitting Receipt, you want to extract all such lines if they also contain an apple or tomato. Also, you want to output apple lines together and then toomato lines.
This is the best I can do without a real Windows computer for testing, and you can configure it here, but it can help:
@echo OFF setlocal enabledelayedexpansion set apples= set tomatos= for /f "delims=" %%l in ('findstr /ilc:"Submitting Receipt" "diflog.txt"') do ( set line=%%l for /f "eol=; tokens=1 delims=" %%s in ('echo !line! ^| findstr /ic:"apple"') do ( set new_apple=%%s set apples=!apples!,!new_apple! ) for /f "eol=; tokens=1 delims=" %%s in ('echo !line! ^| findstr /ic:"tomato"') do ( set new_tomato=%%s set tomatos=!tomatos!,!new_tomato! ) ) echo Apples: for /f "eol=; tokens=1 delims=," %%a in ('echo !apples!') do ( set line_with_apple=@ @a echo !line_with_apple! ) echo Tomatos: for /f "eol=; tokens=1 delims=," %%t in ('echo !tomatos!') do ( set line_with_tomato=@ @a echo !line_with_tomato! )
source share