copy directory from a to b, how?

Steve Holden sholden at bellatlantic.net
Mon Mar 27 20:04:54 CEST 2000


davec999 at my-deja.com wrote:
> 
> In article <8bne0u$jlu$1 at nnrp1.deja.com>,
> tiddlerdeja at my-deja.com wrote:
> > I'd like to copy a directory from c:/Inetpub/staging to
> > c:/Inetpub/wwwroot.
> >
> > How do I do this in Python? I know that I have shutil.copytree() at my
> > disposal, but this requires that the destination directory doesn't
> > exist. I don't want to remove c:/Inetpub/wwwroot so that I can perform
> > the copy.
> >
> > What is the best way to do this? Any help appreciated.
> Is is essential to do it in Python? I would use the line:
> os.system("xcopy c:\\inetpub\\staging c:\\inetpub\\wwwroot\\ /E")
> Remember the backslashes in the correct place (at the end of the second
> argument and not at the end of the first) and you should be fine.
> Of course, if you want it to work on multiple OSs this will obviously
> not work. :)
> Dave
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Also be aware of the various nastinesses that NT (this *is* an NT problem,
right?) will put in your way: the C:\Inetpub\wwwroot directory may well
be impossible to rename or delete, which I suspect is the motivation
behind the original question.

If you were to stop the WWW publishing service you should find that you
can delete all files and subdirectories (use os.path.walk to find them)
from the existing web, and replace the old web with a new one either by\
using walk again or by the effective method suggested above.

regards
 Steve
--
"If computing ever stops being fun, I'll stop doing it"



More information about the Python-list mailing list