Do anyone already have code to copy nested files to a flat directory?
peter at engcorp.com
Tue Mar 21 03:45:18 CET 2006
> OK, please don't bother. Here is my wheel :-)
> import os
> import shutil
> def CopyFlat(source, target):
> count = 0
> for root, dirs, files in os.walk(source):
> for file in files:
> count += 1
> name = root + '\\' + file
A small improvement to the reinvented wheel: use os.sep instead of "\\",
for portability. Better yet, use os.path.join() and avoid the manual
joining of path parts.
More information about the Python-list