How do you copy files from one location to another?

John Salerno johnjsal at gmail.com
Fri Jun 17 12:17:24 EDT 2011


On Jun 17, 2:25 am, Gregory Ewing <greg.ew... at canterbury.ac.nz> wrote:
> John Salerno wrote:
> > 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,
>
> It sounds like shutil.copy() is what you want, or one of the
> other related functions in the shutil module.
>
> --
> Greg


shutil.copy(src, dst)
Copy the file src to the file or directory dst. If dst is a directory,
a file with the same basename as src is created (or overwritten) in
the directory specified. Permission bits are copied. src and dst are
path names given as strings.



This looks promising! But can src be a directory, or does it have to
be a file? For my purposes (copying a saved games folder), I don't
really need to specify particular files to copy, I just need to copy
the entire Saved Games directory, so that's what would be my src
argument if allowed.

Also, the directory I want to copy also contains a directory. Will the
contents of that directory also be copied, or do I have to do some
kind of walk-through of the directory manually?



More information about the Python-list mailing list