title: Python subprocess.Popen() wait for completion
body: <p>I am writing a small script to serially walk through a directory and run a command on the subdirectories therein.</p>
  
  <p>I am running into a problem however with <a href="https://docs.python.org/library/subprocess.html#popen-constructor" rel="noreferrer">Popen()</a> that it will walk through the directories and run the desired command without waiting for the previous one to finish. i.e.</p>
  
  <pre><code>for dir in dirs:
      #run command on the directory here.
  </code></pre>
  
  <p>it kicks off the command for each dir without caring about it afterwards. I want it to wait for the current one to finish, then kick off the next. The tool I am using on the directories is <code>Log2timeline</code> from SANS SIFT which takes quite a while and produces quite a bit of output. I don't care about the output, I just want the program to wait before kicking off the next.</p>
  
  <p>What's the best way to accomplish this?</p>
  
  <p>Thank you!</p>