Wednesday, 15 September 2010

copy - Python shutil.copytree() is there away to track the status of the copying -



copy - Python shutil.copytree() is there away to track the status of the copying -

i have lot of raster files (600+) in directories need re-create new location (including directory structure). there way track status of copying using shutil.copytree()? files utilize code below, not sure how same shutil.copytree():

for currentfolder, subfolder, filenames in os.walk(sourcefolder): in filenames: if i.endswith(".img"): print "copying {}".format(i) shutil.copy(os.path.join(currentfolder,i), outputfolder)

yes, possible taking advantage of function name passed in 'ignore' parameter. in fact given in illustration section of python docs: https://docs.python.org/2/library/shutil.html#copytree-example

example pasted below well:

from shutil import copytree import logging def _logpath(path, names): logging.info('working in %s' % path) homecoming [] # nil ignored copytree(source, destination, ignore=_logpath)

python copy

No comments:

Post a Comment