title: Select files in directory and move them based on text list of filenames
body: <p>So I have a folder of a few thousand pdf files in /path, and I have a list of hundreds of names called names.csv (only one column, it could just as easily be .txt).</p>
  
  <p>I'm trying to select (and ideally, move) the pdfs, where any name from names.csv is found in any filename. </p>
  
  <p>From my research so far, it seems like listdir and regex is one approach to at least get a list of the files I want:</p>
  
  <pre><code>import os, sys  
  import re 
  
  
  for files in os.listdir('path'):
      with open('names.csv') as names: 
          for name in names:
              match  = re.search(name, files)
  
          print match  
  </code></pre>
  
  <p>But currently this is just returning 'None' 'None' etc, all the way down. </p>
  
  <p>I'm probably doing a bunch of things wrong here. And I'm not even near the part where I need to move the files. But I'm just hoping to get over this first hump. </p>
  
  <p>Any advice is much appreciated!</p>