copy directory from a to b, how?

tiddlerdeja at my-deja.com tiddlerdeja at my-deja.com
Tue Mar 28 06:28:08 EST 2000


Why use os.path.walk() to delete files? Am I missing something here?

Would it not just be easier to use shutl.rmtree() ?

Also, I hadn't thought that there may be a permission/sharing issue
with c:\inetpub\wwwroot. I just didn't want to remove it as it may take
some time if wwwroot stores a large number of files. I also felt it to
be a bit unknerving that I would be remving the root directory of my
web server.



In article <38DFA2DD.4C2EE42C at bellatlantic.net>,
sholden at BellAtlantic.net wrote:
> 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"
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list