title: How do I copy files by date created?
body: <p>I am trying to copy files from one folder to another. Sometimes the folder has 5 gigs worth of files, but I only need two months worth of files. How do I tell python to copy files from a date range of today to 2 months ago?</p>
  <p>example: copy files created on 2.4.2022 - 4.4.2022.</p>
  <p>would I do:</p>
  <pre><code>import shutil
  import datetime
  
  for file in range(2.4.2022, 4.4.2022):
      shutil.copy('C:\\folder', 'C:\\folder2')
  </code></pre>
  <p>I need python to automatically use today's date. So when the code is run Python will use the date range of, the date that the code is run to two months ago.</p>
  <p>Thank you for your help!</p>
  <p>I am not good with python yet.  I was able to use <code>shutil.copytree</code> for one folder. That worked because I need all the files in that particular folder, as for the second folder I don't need all the files.</p>