title: Batch file to list all folders in a directory and output to txt with
body: <p>I am trying to create a batch file to parse a directory Z:\ (not including sub folders) which is a mapped network drive to give all folders that name includes "COMPANY_*" and output those folder names with the the full path to a text file.</p>
  
  <p>The text file will be saved to a program folder location which is referenced when you run the program.</p>
  
  <p>For example</p>
  
  <p>Dir:</p>
  
  <ul>
  <li>Z:\Company_001</li>
  <li>Z:\def</li>
  <li>Z:\Comapny_002</li>
  <li>Z:\Company_101</li>
  </ul>
  
  <p>Text file:</p>
  
  <ul>
  <li>Z:\Company_001</li>
  <li>Z:\Company_002</li>
  <li>Z:\Company_101</li>
  </ul>
  
  <p>I started to have a go but dont know what I am doing and need to run this batch on 10 computers so do not want to cause any problems.</p>
  
  <pre><code>dir "Z:\" /b &gt;d:\test.txt
  FOR /F "delims=" %%a in (test.txt) do @echo Z:\%%a&gt;&gt;output.txt
  del "d:\test.txt"
  start C:\Windows\System32\notepad.exe "d:\output.txt"
  pause
  </code></pre>