April 22nd, 2013, 07:51 AM
Shutil module replacing file irrespective of extension
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!
April 22nd, 2013, 10:32 AM
Used correctly, shutil will copy files as you want. Post the relevant piece of code (with tags).