title: Selecting files by date and containing text, Python
body: <p>I'm trying to select specific files in Windows within a specified timeframe, and if it includes specific text.</p>
  
  <pre><code>for folderName, subfolders, filenames in os.walk(r'C:\User\Documents\Reports'):
  
      for file in filenames:
              if os.path.getmtime(file) &lt; datetime.timedelta(days=31) AND if 'Summary' in file or 'Summaries' in file :
                      try: shutil.copy(os.path.join(folderName, file), r'C:\User\Documents\File_Selections')
                      except: 
                              print(folderName, file)
  </code></pre>
  
  <p>So I'm looking through the Reports folder for each file that was last modified in the last month, AND if it's name includes 'summary' or 'summaries'. I then want to copy each file to a specific folder and print out the results. </p>
  
  <p>My main problem is how does the date comparison work, so that only files modified in the last month are selected? Also I was unsure if the AND operator is being used correctly within the 'if' statement.</p>