Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7849

Re: How do you copy files from one location to another?

From Terry Reedy <tjreedy@udel.edu>
Subject Re: How do you copy files from one location to another?
Date 2011-06-17 15:23 -0400
References <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> <960dr2Fi6oU1@mid.individual.net> <7b3bf7e0-9691-4127-b332-f2224c70c4b1@y7g2000prk.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.89.1308338596.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 6/17/2011 12:17 PM, John Salerno wrote:
> On Jun 17, 2:25 am, Gregory Ewing<greg.ew...@canterbury.ac.nz>  wrote:

>> It sounds like shutil.copy() is what you want, or one of the
>> other related functions in the shutil module.

> 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.

If you follow the second part of Greg's suggestion 'or one of the other 
related function in the shutil module', you will find copytree()
"Recursively copy an entire directory tree rooted at src. "
>
> 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?

If you want more control of which files to copy, between 1 and all, look 
as os.walk and the glob module.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-16 22:06 -0700
  Re: How do you copy files from one location to another? Andrew Berg <bahamutzero8825@gmail.com> - 2011-06-17 01:15 -0500
  Re: How do you copy files from one location to another? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-17 19:25 +1200
    Re: How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-17 09:17 -0700
      Re: How do you copy files from one location to another? Terry Reedy <tjreedy@udel.edu> - 2011-06-17 15:23 -0400
        Re: How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-17 14:27 -0700
          Re: How do you copy files from one location to another? Ethan Furman <ethan@stoneleaf.us> - 2011-06-17 15:15 -0700
            Re: How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-17 16:28 -0700
  Re: How do you copy files from one location to another? Tim Golden <mail@timgolden.me.uk> - 2011-06-17 09:04 +0100
  Re: How do you copy files from one location to another? Heather Brown <heather@dejaviewphoto.com> - 2011-06-17 12:43 -0400
  Re: How do you copy files from one location to another? Michael Hrivnak <mhrivnak@hrivnak.org> - 2011-06-18 13:13 -0400
  Re: How do you copy files from one location to another? Terry Reedy <tjreedy@udel.edu> - 2011-06-18 16:52 -0400

csiph-web