example - simply replaces the "fromdirectory path string with the "todirectory path stringat the front of all directory names and pathnames passed in from os walk the results of the string replacements are the paths to which the original files and directories are to be copied example - pp \tools\visitor_cpall py ""use"python \tools\visitor_cpall py fromdir todir trace?like system\filetools\cpall pybut with the visitor classes and os walkdoes string replacement of fromdir with todir at the front of all the names that the walker passes inassumes that the todir does not exist initially""import os from visitor import filevisitor from pp system filetools cpall import copyfile visitor is in pp is in dir on path class cpallvisitor(filevisitor)def __init__(selffromdirtodirtrace=true)self fromdirlen len(fromdir self todir todir filevisitor __init__(selftrace=tracedef visitdir(selfdirpath)topath os path join(self todirdirpath[self fromdirlen:]if self traceprint(' 'dirpath'=>'topathos mkdir(topathself dcount + def visitfile(selffilepath)topath os path join(self todirfilepath[self fromdirlen:]if self traceprint(' 'filepath'=>'topathcopyfile(filepathtopathself fcount + if __name__ ='__main__'import systime fromdirtodir sys argv[ : trace len(sys argv print('copying 'start time clock(walker cpallvisitor(fromdirtodirtracewalker run(startdir=fromdirprint('copied'walker fcount'files,'walker dcount'directories'end='print('in'time clock(start'seconds' complete system programs