How do you copy files from one location to another?

John Salerno johnjsal at gmail.com
Fri Jun 17 01:06:58 EDT 2011


Based on what I've read, it seems os.rename is the proper function to
use, but I'm a little confused about the syntax. Basically I just want
to write a simple script that will back up my saved game files when I
run it. So I want it to copy a set of files/directories from a
location on my C:\ drive to another directory on my E:\ drive. I don't
want to rename or delete the originals, just move them. I also want
them to automatically overwrite whatever already happens to be in the
location on the E:\ drive.

Is os.rename the proper function for this? Mainly I was because the
Module Index says this:

"On Windows, if dst already exists, OSError will be raised even if it
is a file.."

so it sounds like I can't move the files to a location where those
file names already exist.



More information about the Python-list mailing list