Skip to content Skip to sidebar Skip to footer

Windowserror: [error 183] Cannot Create A File When That File Already Exists

I am using the following script to add a copy right to all the files in the directories and subdirectories for a give directory passed as first argument ,am running the script as f

Solution 1:

If you want to append to an existing file, you need something like:

with open(fullname, "ab") as in_file

Q: Are you sure you can use shutil.copyfileobj(in_file, out_file) with an open out_file that you've already written to?

Q: Do you know which line is causing the windows error?

Thank you for the update.

I'll bet your directory already has a file already named fullname, hence os.rename(temp_fname, fullname) fails with "file already exists".

Q: Would shutil.move work instead?

Post a Comment for "Windowserror: [error 183] Cannot Create A File When That File Already Exists"