pathto os path join(dirtofilenameextend both paths if not os path isdir(pathfrom)copy simple files tryif verbose print('copying'pathfrom'to'pathtocopyfile(pathfrompathtofcount + exceptprint('error copying'pathfrom'to'pathto'--skipped'print(sys exc_info()[ ]sys exc_info()[ ]elseif verboseprint('copying dir'pathfrom'to'pathtotryos mkdir(pathtomake new subdir below copytree(pathfrompathtorecur into subdirs fcount +below[ add subdir counts dcount +below[ dcount + exceptprint('error creating'pathto'--skipped'print(sys exc_info()[ ]sys exc_info()[ ]return (fcountdcountdef getargs()""get and verify directory name argumentsreturns default none on errors ""trydirfromdirto sys argv[ :exceptprint('usage errorcpall py dirfrom dirto'elseif not os path isdir(dirfrom)print('errordirfrom is not directory'elif not os path exists(dirto)os mkdir(dirtoprint('notedirto was created'return (dirfromdirtoelseprint('warningdirto already exists'if hasattr(os path'samefile')same os path samefile(dirfromdirtoelsesame os path abspath(dirfrom=os path abspath(dirtoif sameprint('errordirfrom same as dirto'elsereturn (dirfromdirtoif __name__ ='__main__'import time dirstuple getargs(if dirstupleprint('copying 'start time clock( complete system programs