Renaming OS files by file type in python

MRAB python at mrabarnett.plus.com
Thu Aug 12 12:16:08 EDT 2010


blur959 wrote:
> Hi all, I am creating a program that renames all files of the similar
> file type. But i am stuck at this part. I tried running this code and
> I got this error:    new_name = os.rename(path, newpath)
> WindowsError: [Error 183] Cannot create a file when that file already
> exists. Hope you guys could help.
> 
[snip]
As the traceback says, a file with that new name already exists. You
can't have 2 files with the same name in the same folder.



More information about the Python-list mailing list