title: Python - How to copy only new modified files
body: <p>I am trying to write a python script that will copy certain files from a source folder to a destination, however only newly created files should be copied.
  For example, the source folder contains 2005 files and the destination folder contains 2000 of them, my script should copy the 5 missing files </p>
  
  <p>In the script below, the logic was to log the modification time of the files with extension ".extension" and trying to get it and compare it in next step</p>
  
  <pre><code>import sys, os, shutil
  import glob
  import os.path, time
  
  fob     = open(r"C:\Python\Log.txt","a")
  dir_src = r"C:\Python\Source"
  dir_dst = r"C:\Python\Dest"
  
  for w in os.listdir(dir_src):
      if w.endswith('.extenstion'):
          pathname = os.path.join(dir_src, w)
          if not Date_File in (fob):
              shutil.copy2(pathname, dir_dst)
              fob.write("File Name:   %s" % os.path.basename(pathname))
              fob.write("   Last modified Date:   %s" % time.ctime(os.path.getmtime(pathname)))
              fob.write("   Copied On:   %s" % time.strftime("%c"))
              fob.write("\n")                
  fob.close()
  os.system("PAUSE")
  </code></pre>
  
  <p>I could not find a way to compare the dates and check either a file should be copied or not.</p>
  
  <p>Any other approach is welcome.</p>