title: Batch to pattern matching in a loop
body: <p>I am trying to loop through a file which contains few names and search the same with two patterns in another file and echo some statements.</p>
  
  <p>Like I have two files :</p>
  
  <p>1.Installers.txt
  2.Progress.txt</p>
  
  <ol>
  <li><p>Installers.txt</p>
  
  <pre><code>  abc.jar
     def.jar
     tef.jar
     ....
        ....
  </code></pre></li>
  <li><p>Progress.txt</p>
  
  <pre><code>   abc.jar deployment started
     abc.jar deployed successfully
     def.jar deployment started
  </code></pre></li>
  </ol>
  
  <p>So my requirement is to read the Installers.txt file one line at a time and search for the 2 patterns "abc.jar deployment started" and "abc.jar deployed successfully" and report successful or else if both patterns are yet to be found to show as still in progress.</p>
  
  <p>I have tried writing below but its failing at many things while doing pattern and the logic also does not look good. can someone help here.</p>
  
  <pre><code>          for /F "usebackq delims=" %%a in ("Installer.txt") do (
     set /A i+=1
        call echo installing %%i%% : %%a
            :NOTVALID
         findstr /I "%%k\ in\ progress" %1%\progress.txt
                If errorlevel 1 (
                echo "installation still in progress.."
                 PING 127.0.0.1 -n 1 &gt;NUL 2&gt;&amp;1 || PING ::1 -n 1 &gt;NUL 2&gt;&amp;1
                goto NOTVALID 
              ) else (
                    set /A i+=1
                    echo "installation completed.."
  
                  call set array[%%i%%]=%%a
                   call set n=%%i%%
                    )
  </code></pre>