synching with os.walk()
meyer at acm.org
Fri Nov 24 18:05:30 CET 2006
What I forgot to mention is that I want this to run unmodified from both
Windows and Linux (and Mac). Otherwise, there are enough options to choose
from, besides developing it myself, I guess.
On 24 Nov 2006 08:37:13 -0800, Paddy <paddy3118 at netscape.net> wrote:
> Paddy wrote:
> > Andre Meyer wrote:
> > > Hi all
> > >
> > > os.walk() is a nice generator for performing actions on all files in a
> > > directory and subdirectories. However, how can one use os.walk() for
> > > through two hierarchies at once? I want to synchronise two directories
> > > backup for now), but cannot see how I can traverse a second one. I do
> > > now with os.listdir() recursively, which works fine, but I am afraid
> > > recursion can become inefficient for large hierarchies.
> > >
> > > thanks for your help
> > > André
> > Walk each tree individually gathering file names relative to the head
> > of the tree and modification data.
> > compare the two sets of data to generate:
> > 1. A list of what needs to be copied from the original to the copy.
> > 2. A list of what needs to be copied from the copy to the original
> > Do the copying.
> > |You might want to show the user what needs to be done and give them
> > the option of aborting after generating the copy lists.
> > - Paddy.
> P.S. If you are on a Unix type system you can use tar to do the copying
> as you can easily compress the data if it needs to go over a sow link,
> and tar will take care of creating any needed directories in the
> destination if you create new directories as well as new files.
> - Paddy.
Dr. Andre P. Meyer http://python.openspace.nl/meyer
TNO Defence, Security and Safety http://www.tno.nl/
Delft Cooperation on Intelligent Systems http://www.decis.nl/
Ah, this is obviously some strange usage of the word 'safe' that I wasn't
previously aware of. - Douglas Adams
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list