En Sat, 05 Apr 2008 20:56:31 -0300, <[EMAIL PROTECTED]> escribió:

> I am writing a script that will backup specified folders from one hard
> drive to another (for example, backup source "C:\DATA", destination "D:
> \Backup"), and was thinking of using shutil.  What I would like to do
> is recursively backup the specified directories (which copytree will
> do), but be able to specify exclusion directories (which copytree does
> not appear to allow you to do).  My initial thoughts were I'll
> probably have to use os.path.walk for the backup source directory, but
> I'm not sure how to go from there.  Thanks in advance.

I'd use os.walk (not os.path.walk) and shutil.copy2; use os.makedirs to  
create the target directory (only when it doesn't already exist).
If you remove directories from the dirnames list, they're not recursed  
into.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to