title: Loop through files in subdirectories batch file
body: <p>I am trying to loop through a bunch of files in sub-directories to run a command on them, but I can't seem to figure out how to reach them.</p>
  
  <p>The directory structure is like this:</p>
  
  <ul>
  <li>Main directory (Holds .bat file and top-level directories)
  
  <ul>
  <li>Sub-directory
  
  <ul>
  <li>Search directory
  
  <ul>
  <li>A bunch of files (I need the locations of all of these separately)</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>I am able to get a list of all of the files/folders in the "Main directory" using:</p>
  
  <pre><code>for /f %%f in ('dir /b /r *') do echo %%f
  </code></pre>
  
  <p>but I cannot seem to figure out how to go any further into the directories to get the files in the "Search" directory.</p>
  
  <p>An example of the file structure is:</p>
  
  <pre><code>C:\Users\swiftsly\Search160\0002\search\AP584.txt
  </code></pre>
  
  <p>Any help is greatly appreciated!</p>