title: Is it possible in a batch file to read from a pipe line by line?
body: <p>I was wondering if it is possible to read from a pipe in a batch file. If I write:</p>
  
  <pre><code>echo Test
  </code></pre>
  
  <p>i get, unsurprising, <code>Test</code>. That's nice. But what if I want to pipe the output, and read it from another command?</p>
  
  <pre><code>echo Test | echo ???
  </code></pre>
  
  <p>How to obtain the same result as before, but through a pipe?
  Thanks!</p>
  
  <p><strong>EDIT:</strong> what I am after really after is this.</p>
  
  <p>I have a list of files, and i need to filter this list with some words that i put, line by line, in a file named <code>filter.txt</code>. So I have to use <code>findstr /g:filter.txt</code>.</p>
  
  <p>But then I need to do something to the list files that matches, and since <code>findstr</code> returns one row for each file, i have to read the matches line by line.</p>
  
  <p>This is how i did it:</p>
  
  <pre><code>dir /b | findstr /g:filter.txt | for /F "delims=" %a in ('more') do del "%a"
  </code></pre>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>It looks like that what I wanted to do was not <em>reading from a pipe</em> but just <em>reading the output of another command</em> in a batch file.</p>
  
  <p>To do a single line read, you could use this:</p>
  
  <pre><code>echo Test | ( set /p line= &amp; call echo %%line%%)
  </code></pre>
  
  <p>or you can use this, that works also with multi line input:</p>
  
  <pre><code>echo Test | for /F "delims=" %a in ('more') do @echo %a
  </code></pre>
  
  <p>(this trick of using <em>more</em> could be useful in some situations). But in my particular case, the solution is this:</p>
  
  <pre><code>for /F "delims=" %a in ('echo Test') do @echo %a
  </code></pre>
  
  <p>Thanks to everyone!</p>