[Tutor] shutils.copytree

Tim Golden mail at timgolden.me.uk
Fri Jan 11 10:02:49 CET 2008


Kent Johnson wrote:
> Tony Cappellini wrote:
>> I'm using shutils for the first time, and I've un into a problem.
>> The docs for copytree are pretty sparse and don't mention any problem situations
>>
>> Under WinXP, I'm trying to copy a directory tree to a USB device using
>> copytree, but copytree doesn't like a drive letter as a destination.
>>
>> copytree('C:\\testdir', 'g:\\')
> 
> The source for copytree says, "The destination directory must not 
> already exist." I suppose that is why you have a problem but I don't 
> know the specific cause. Did you get a traceback?
> 
> The source also says, "Consider this example code rather than the 
> ultimate tool" so maybe you should just copy it and make a version that 
> does what you want. See shutil.py in your Python lib directory.

Also -- vaguely -- have a look at my notes on file copying
under windows to consider alternatives:

http://timgolden.me.uk/python/win32_how_do_i/copy-a-file.html

TJG


More information about the Tutor mailing list