#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    Unhappy Shutil module replacing file irrespective of extension


    Hello,

    I have a problem, I had to copy files from 1 directory to another if both the directories have files with the same name. The first dir will have files with .ext1 and the second one will files with .ext2. But the file names would be the same. So, when I copy files from the first dir to the second dir I dont want the files to be be replaced, rather I want both files with the same name but with different .ext to be present in the dest dir.
    I have written the script, but I have used the shutil module. This copies the file to the dest dir but it replaces the file if it has the same name. It doesn't take the .ext into consideration. Both these files have different .ext.

    Is there a way, to copy the file from source to dest, wherein the dest dir will contain both files with different extensions.

    Would appreciate any help. Thank you!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    39N 104.28W
    Posts
    156
    Rep Power
    2
    Used correctly, shutil will copy files as you want. Post the relevant piece of code (with tags).

IMN logo majestic logo threadwatch logo seochat tools logo