[Tutor] Copy without overwrite?
python at bernardlebel.com
Tue Sep 21 14:31:25 CEST 2004
Unless I'm missing something... os.copytree() expects the destination directory to not exists. It it
exists, the function aborts instead of visiting the said directory and go further down the tree.
Plus, I don't think it handles individual files (files are copied, but no determining of existence
Let me know if I'm missing something.
----- Original Message -----
From: "Kent Johnson" <kent_johnson at skillsoft.com>
To: <tutor at python.org>
Sent: Tuesday, September 21, 2004 2:17 PM
Subject: Re: [Tutor] Copy without overwrite?
> shutil.copytree() is almost what you want. You could copy it (from
> Python/Lib/shutil.py) and check os.path.exists() before the actual copying
> is done.
> At 11:59 AM 9/21/2004 +0200, Bernard Lebel wrote:
> >Is there a simple way to copy files and directory without any overwriting
> >if the destination tree
> >structure contains files and directory of the same name? Basically that
> >would just add new elements
> >to the destination structure, and leave the existing structure intact.
> >Tutor maillist - Tutor at python.org
> Tutor maillist - Tutor at python.org
More information about the Tutor