title: How to check to see if a folder contains files using python 3
body: <p>I've searched everywhere for this answer but can't find it.</p>
  
  <p>I'm trying to come up with a script that will search for a particular subfolder then check if it contains any files and, if so, write out the path of the folder. I've gotten the subfolder search part figured out, but the checking for files is stumping me.</p>
  
  <p>I have found multiple suggestions for how to check if a folder is empty, and I've tried to modify the scripts to check if the folder is not empty, but I'm not getting the right results.</p>
  
  <p>Here is the script that has come the closest:</p>
  
  <pre><code>for dirpath, dirnames, files in os.walk('.'):
  if os.listdir(dirpath)==[]:
      print(dirpath)
  </code></pre>
  
  <p>This will list all subfolders that are empty, but if I try to change it to:</p>
  
  <pre><code>if os.listdir(dirpath)!=[]:
      print(dirpath)
  </code></pre>
  
  <p>it will list everything--not just those subfolders containing files.</p>
  
  <p>I would really appreciate it if someone could point me in the right direction.</p>
  
  <p>This is for Python 3.4, if that matters.</p>
  
  <p>Thanks for any help you can give me.</p>