Cool, this seems to work. thanks!
On 24 Nov 2006 08:12:08 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> 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 walking > through two hierarchies at once? I want to synchronise two directories (just > backup for now), but cannot see how I can traverse a second one. I do this > now with os.listdir() recursively, which works fine, but I am afraid that > recursion can become inefficient for large hierarchies. I've run into wanting to work with parallel directory structures before, and what I generally do is something like: for root, dirs, files in os.walk( dir1 ): dir2_root = dir2 + root[len(dir1):] for f in files: dir1_path = os.path.join( root, f ) dir2_path = os.path.join( dir2_root, f ) Does this work for your needs? -- Nils -- http://mail.python.org/mailman/listinfo/python-list
-- 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
-- http://mail.python.org/mailman/listinfo/python-list