title: How do I find a directory in and store it into a variable, using a Windows batch file?
body: <p>I need to find the location of a specific directory, and then store that directory path into a variable within a Windows batch script.</p>
  
  <p>I also want the command to return when it finds a match (to avoid searching the entire hard drive once the directory has already been found).</p>
  
  <p>So far I've tried this on the command line:</p>
  
  <pre><code>dir c:\ /s /b /ad | find "DirectoryName"
  </code></pre>
  
  <p>The problem with this is that it searches the entire drive, even after a match is found. Plus, I still can't figure out how to store the result in a variable within a batch file. There should only be a single result.</p>
  
  <p>Basically I need the equivilent of somehting like this on Linux/bash:</p>
  
  <pre><code>export DIRPATH=`find / -name "DirectoryName" -print -quit`
  </code></pre>
  
  <p>Thanks for looking!</p>