title: How to synchronize two folders using python script
body: <p>Currently, I am working on a project in which am synchronizing two folders. My folders in the following example names ad <strong>Folder_1 as source</strong> and <strong>Folder_2 as destination</strong> I want to do the following things.</p>
  
  <ol>
  <li>If files which are present in Folder_1 are not present in Folder_2,
  copy the files from folder_1 to Folder_2 and <strong>Vice Versa</strong>.</li>
  <li>If I rename any file in either folder, it gets updated in the other folder instead of copying a new file with the updated name.</li>
  <li>if I delete any file from any folder, it should get deleted from the other folder as well. </li>
  </ol>
  
  <p>I have done half the part of point one in which I am able to copy the files from Folder_1 to Folder_2. Send part where I could be able to copy files from Folder_2 to folder_1 is still remaining.</p>
  
  <p>Following is my code</p>
  
  <pre><code>import os, shutil
  path = 'C:/Users/saqibshakeel035/Desktop/Folder_1/'
  copyto = 'C:/Users/saqibshakeel035/Desktop/Folder_2/'
  
  files =os.listdir(path)
  files.sort()
  for f in files:
          src = path+f
          dst = copyto+f
          try:
                  if os.stat(src).st_mtime &lt; os.stat(dst).st_mtime:
                          continue
          except OSError:
                          pass
                          shutil.copy(src,dst)#this is the case when our file in destination doesn't exist
                                 =
  print('Files copied from'+ path +'to' + copyto+ '!')
  </code></pre>
  
  <p>What can I amend or do so that I can synchronize both folders completely?
   Thanks in advance :)</p>