title: Batch script to get a list of all files in multiple subdirectories
body: <p>I'd like to create a batch script that will create a list of all files in a directory. </p>
  
  <p>So far here's what I have:</p>
  
  <pre><code>@echo off
  
  dir c:\users\documents\* /b &gt; filelist.txt
  </code></pre>
  
  <p>This works perfectly with one small hitch. The files I want to get for the list are nestled in multiple user directories which are nestled inside two directories (A-L / M-Z). I can get around the two alphabetical directories easily by just writing two lines for this. However, I'm not sure how to get a list of the files inside of the sub-directories.</p>
  
  <p>BONUS: This is an extra bit that I haven't actually researched yet but thought I'd throw it in there. I'm going to try and get this script to attach the "filelist.txt" to an email and send it out automatically. </p>
  
  <p>EDIT: Forgot a much more important bonus problem. </p>
  
  <p>Here's a really pitiful illustration of the file structure.</p>
  
  <p><a href="https://i.stack.imgur.com/XfLU0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XfLU0.png" alt="enter image description here"></a></p>
  
  <p>I'd like to be able to have a list that shows the parent directory to the files so that it would show up something like this in the filelist.txt: "A Name\File1.ext"</p>
  
  <p>EDIT: Using <code>dir /b/s</code> seems to list all subdirectories, files and gives the full path length. Is there any way to only return a list when there is something in a particular one of the "Name directories"? So if everything but "D Name" is empty, it will only return </p>
  
  <pre><code>\D Name\file1.ext
  \D Name\file2.ext
  </code></pre>