Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sysadmin': 0.04; 'raised': 0.07; 'python': 0.08; 'overwrite': 0.09; 'rename': 0.09; 'subject:files': 0.09; 'syntax.': 0.09; 'tasks,': 0.09; 'this:': 0.10; 'am,': 0.14; 'wrote:': 0.14; '"on': 0.16; 'dst': 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; 'fri,': 0.23; 'index': 0.25; 'function': 0.25; 'url:mailman': 0.26; 'mainly': 0.26; 'says': 0.27; 'script': 0.27; "i'm": 0.27; 'sender:addr:gmail.com': 0.28; 'message-id:@mail.gmail.com': 0.28; 'subject:?': 0.29; 'instead': 0.29; 'subject:How': 0.30; 'cc:addr:python.org': 0.30; 'url:listinfo': 0.30; 'module': 0.30; 'confused': 0.30; 'exist.': 0.30; 'exists,': 0.30; 'received:209.85.215': 0.30; 'received:209.85.215.46': 0.30; 'received:mail-ew0-f46.google.com': 0.30; 'changes': 0.30; 'it.': 0.31; 'this.': 0.31; 'michael': 0.32; "can't": 0.32; 'copying': 0.33; "i've": 0.33; 'file': 0.34; 'done.': 0.34; '17,': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'another': 0.37; 'url:python': 0.38; 'subject:from': 0.38; 'url:org': 0.38; 'run': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'perhaps': 0.39; 'received:209': 0.39; 'read,': 0.40; 'delete': 0.40; 'john': 0.62; 'back': 0.63; 'benefit': 0.70; 'subject:one': 0.77; 'subject:you': 0.80; 'drive.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=tvAG1x6IGnsNWUEC9OH4/9YyM+PwG7kYeRMMds+lHTo=; b=iUfDZsOww/Sw+RSihHW07yDEW4okSmoNn4ipvC2gNOmum2LN6ky3Et5QK2oEOaa/I/ 7Z05lAyhNhNce1XEcDBKE6JtkOdlrqxDKTPi/ROigPqE8ThE3rOFXm8/Ob0kyM4HlqfY e2N1mX+FnRqGfNXb/X0t/B/8gv4JPO9bQdkq0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=QWwJ3f2ZzO4RDfwXRMc7xUrzJ5/7VGqgChTjrApxc1psBUaL//Q+SNlGwUxPRbvxFI XP9AiclBiSY01W3IOucqStbHHrxR/1dSRFlj5R3rExx/3p8HgO3aI/nhT0mnFGcXAttP 8YI0rFEYh0tiOcRBkxU4dYyMb8/kSgyrWaFw8= MIME-Version: 1.0 Sender: mhrivnak@gmail.com In-Reply-To: <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> References: <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> Date: Sat, 18 Jun 2011 13:13:36 -0400 X-Google-Sender-Auth: FGFyLErRqJ6AdNHfbrwohQf1SJU Subject: Re: How do you copy files from one location to another? From: Michael Hrivnak To: John Salerno Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: 29 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308417218 news.xs4all.nl 49045 [::ffff:82.94.164.166]:35328 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7916 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 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 >