How do you copy files from one location to another?

Michael Hrivnak mhrivnak at hrivnak.org
Sat Jun 18 13:13:36 EDT 2011


Python is great for automating sysadmin tasks, but perhaps you should
just use rsync for this.  It comes with the benefit of only copying
the changes instead of every file every time.

"rsync -a C:\source E:\destination" and you're done.

Michael

On Fri, Jun 17, 2011 at 1:06 AM, John Salerno <johnjsal at gmail.com> wrote:
> 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.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list