title: Get files that have certain extension and contain certain words in their folder?
body: <p>I want to make a code that finds files in the subfolders given a main folder  that has certain extension and contain some words in their subfolder's name. How can i do that? </p>
  
  <p>For example get files where their folder has the words 'dis' in their name and get the files that have <code>shp</code> extension in them.</p>
  
  <p>Here is what I tried: </p>
  
  <p>Only the part with the name is not covered.</p>
  
  <pre><code>rootfolder= directory
  
  shapelist = []
     for path, subdirs, files in os.walk(rootfolder):
         for name in files:
             if name.endswith('.shp'):
                 shapelist.append(os.path.join(path, name))
  </code></pre>
  
  <p>The tree is like: </p>
  
  <pre><code>rootfolder\
      subfolders(including two that have the words diss)\
          files inside these
  </code></pre>
  
  <p>Hope it is clear.</p>