Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'mentioned,': 0.04; 'raised': 0.07; '(it': 0.09; 'overwrite': 0.09; 'rename': 0.09; 'subject:files': 0.09; 'syntax.': 0.09; 'pm,': 0.10; 'this:': 0.10; 'wrote:': 0.14; '"on': 0.16; 'dst': 0.16; 'from:addr:heather': 0.16; 'oserror': 0.16; 'subject:copy': 0.16; 'cc:addr:python-list': 0.17; 'this?': 0.19; 'header:In-Reply- To:1': 0.21; 'seems': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'similarly': 0.23; 'greg': 0.25; 'index': 0.25; 'function': 0.25; 'saying': 0.26; 'mainly': 0.26; 'says': 0.27; 'script': 0.27; "i'm": 0.27; 'subject:?': 0.29; 'subject:How': 0.30; 'cc:addr:python.org': 0.30; 'module': 0.30; 'confused': 0.30; 'exist.': 0.30; 'exists,': 0.30; 'it.': 0.31; "can't": 0.32; "i've": 0.33; 'file': 0.34; 'header:User-Agent:1': 0.35; 'another': 0.37; 'subject:from': 0.38; 'run': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'read,': 0.40; 'received:192.168.1': 0.40; 'delete': 0.40; 'john': 0.62; 'back': 0.63; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'subject:one': 0.77; 'subject:you': 0.80; '02:59': 0.84; "doesn't,": 0.84; 'drive.': 0.91; 'move.': 0.91; 'original.': 0.91 Date: Fri, 17 Jun 2011 12:43:58 -0400 From: Heather Brown User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 MIME-Version: 1.0 To: John Salerno Subject: Re: How do you copy files from one location to another? References: <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> In-Reply-To: <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:k16ztu5YZPGRFM2OReQzHZ6d2tTyYXQprzx1EmAGNWR s7oqpLipHa9qbwufdmwM6sYKuJ8oTPYg7sAcCgjpvnsymrq1yg DdyPbDJhCXV24mGPJC9W6iT/C5f1v1dLUGLHX1Cu6j7XaDUfbq Gt65DFUrw9TsvkDVArQSshQ3ZulWoI2WqleR+4LDXsMtDBS8sE sU7N+VKgTtmvPyAua67Fg== Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: heather@dejaviewphoto.com 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: 28 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308329068 news.xs4all.nl 49184 [::ffff:82.94.164.166]:60340 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7832 On 01/-10/-28163 02:59 PM, John Salerno 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. > You keep saying 'move' when you want 'copy.' Even if os.rename would work across drives (it doesn't, on Windows), it still would be removing the original. Similarly with move. As Greg mentioned, you want shutil.copy(), not move nor rename. DaveA