title: Windows Batch help in setting a variable from command output
body: <p>I need to run a simple find command and redirect the output to a variable in a Windows Batch File.</p>
  
  <p>I have tried this:</p>
  
  <pre><code>set file=ls|find ".txt"
  echo %file%
  </code></pre>
  
  <p>But it does not work.</p>
  
  <p>If I run this command it works without problems:</p>
  
  <pre><code>set file=test.txt
  echo %file%  
  </code></pre>
  
  <p>So obviously my command output is not being set to my variable.  Can anyone help?  Thanks</p>