title: Parsing through all folders in a directory
body: <p>I am working with Stata and am a beginner. I have a question regarding grabbing folder names. I have a directory, \Test\abc, that has the following folders like this: </p>
  
  <pre><code>Q100
  Q101
  Q102
  ....
  </code></pre>
  
  <p>I would like to go into each folder, Q* (where * denotes anything after the Q), find a file named "filenameQ*", do something, and then send the output back to \Test\abc. The following code shows the idea of what I want to do, where varlist Q* denotes the array of all the folders in the directory that begin with Q. However, folder names aren't variables, so I'm not sure how to proceed.</p>
  
  <pre><code>cd "\\Test\abc"
  foreach x of varlist Q* /* FOLDER NAMES */ { 
      cd "`x'"
      use "filename`x'" 
      display something and send it back to directory "\\Test\abc"
      cd ..
  } 
  </code></pre>