Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:files': 0.09; 'pm,': 0.10; 'am,': 0.14; 'wrote:': 0.14; 'allowed.': 0.16; 'copied,': 0.16; 'os.walk': 0.16; 'reedy': 0.16; 'shutil': 0.16; 'subject:copy': 0.16; 'argument': 0.16; 'tree': 0.19; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; 'directory.': 0.23; 'gregory': 0.23; 'specify': 0.25; 'function': 0.25; 'suggestion': 0.26; 'subject:?': 0.29; 'all,': 0.30; 'subject:How': 0.30; 'second': 0.30; 'ewing': 0.30; 'looks': 0.31; 'header:X-Complaints-To:1': 0.32; 'does': 0.33; 'to:addr:python- list': 0.33; 'header:User-Agent:1': 0.35; '17,': 0.35; 'module.': 0.35; 'received:org': 0.38; 'subject:from': 0.38; 'but': 0.38; 'purposes': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'header:Mime- Version:1': 0.39; 'to:addr:python.org': 0.39; 'really': 0.40; 'more': 0.60; 'kind': 0.60; 'john': 0.62; 'want,': 0.74; 'subject:one': 0.77; 'subject:you': 0.80; '12:17': 0.84; 'walk- through': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: How do you copy files from one location to another? Date: Fri, 17 Jun 2011 15:23:01 -0400 References: <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> <960dr2Fi6oU1@mid.individual.net> <7b3bf7e0-9691-4127-b332-f2224c70c4b1@y7g2000prk.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: <7b3bf7e0-9691-4127-b332-f2224c70c4b1@y7g2000prk.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308338596 news.xs4all.nl 49048 [::ffff:82.94.164.166]:55186 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7849 On 6/17/2011 12:17 PM, John Salerno wrote: > On Jun 17, 2:25 am, Gregory Ewing 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