title: Python : Compare two folders and move files with the same name from 1 folder to another
body: <p>I have two folders in windows. Both these have files with the same name but with different extension. I'm trying to compare these two folders, and if they have files with the same names I need to copy them from 1 folder to another.</p>
  
  <p>I have done this using batch programs, but I want to do this guys using Python.
  I searched here and got some bits and pieces, however I'm not sure if I'm right? 
  Can you guys please help me out?</p>
  
  <pre><code>exm1=[os.path.splitext(x)[0] for x in os.listdir(r'\Path') if os.path.splitext(x)[1]=='.trn']
  exm2=[os.path.splitext(x)[0] for x in os.listdir(r'\Path') if os.path.splitext(x)[1]=='.trn']  
  </code></pre>