title: How to save files with same name in folder in python?
body: <p>I have two folders with images. Let the two folder names A and B. A contains 100 files and B has only 80 files. Both the files have the same name. I want to save only the 80 files from A which has the same correspondence to B in folder C.</p>
  
  <p>Here is a part of my code. However, it is throwing error :  </p>
  
  <blockquote>
    <p>Required argument 'img' (pos 2) not found.</p>
  </blockquote>
  
  <pre><code>path1= '/home/vplab/Kitty/Saliency Dataset/PiCANet-Implementation/TrainSet/images'
  path_mask= '/home/vplab/Kitty/Saliency Dataset/PiCANet-Implementation/TrainSet/masks'
  save_path = '/home/vplab/Kitty/Saliency Dataset/PiCANet-Implementation/TrainSet/exp'
  for file in os.listdir(path1):
      for file1 in os.listdir(path_mask):
          img_name = file[:-4]
          mask_name =file1[:-4]
          if img_name == mask_name:
              cv2.imwrite(os.path.join(save_path,img_name)) 
  </code></pre>