title: How to rename a file while copying into another directory in python?
body: <p>I would like to copy a file from one directory to another with simultaneously renaming the file in python. The &quot;file&quot; need to be copied as &quot;new-file&quot; without renaming the file in source directory. I tried something like this;</p>
  <pre><code>     import shutil,os
       src_path=&quot;path of source directory&quot;
       dst=&quot;path of destination directory&quot;
       for file in os.listdir(src):
           file_path=os.path.join(src_path,file)
            shutil.copy(file_path,dst/&quot;new&quot;+'-'+file)
  </code></pre>
  <p>However this is not working. I know by using os.rename() module, it can be renamed after copying. However i have files with similar names which will be replacing the already copied files in order to avoid which i need to rename each file as &quot;new-file&quot; along with copying itself.</p>
  <p>Any help is appreciated. Thanks in advance</p>