title: python- run script on multiple files
body: <p>I have a python script which takes the filename as a command argument and processes that file. However, i have thousands of files I need to process, and I would like to run the script on every file without having to add the filename as the argument each time.</p>
  
  <p>The script works well when run on an individual file like this:</p>
  
  <pre><code>myscript.py /my/folder/of/stuff/text1.txt
  </code></pre>
  
  <p>I have this code to do them all at once, but it doesn't work</p>
  
  <pre><code>for fname in glob.iglob(os.path.join('folder/location')):
      proc = subprocess.Popen([sys.executable, 'script/location.py', fname])
      proc.wait()
  </code></pre>
  
  <p>Whenever I run the above code, it doesn't throw an error, but doesn't give me the intended output. I think the problem lies with the fact that the script is expecting the path to a .txt file as an argument, and the code is only giving it the folder that the file is sitting in (or at least not a working absolute reference).</p>
  
  <p><strong>How to correct this problem?</strong></p>