i have function:
def path_clone( source_dir_prompt, destination_dir_prompt) : try: shutil.copytree(source_dir_prompt, destination_dir_prompt) print("potentially copied?") except oserror e: # if error caused because source wasn't directory if e.errno == errno.enotdir: shutil.copy(source_dir_prompt, destination_dir_prompt) else: print('directory not copied. error: %s' % e) why failing , outputting :
directory not copied. error: [errno 17] file exists: '[2]' my source directory exists files/directory. destination folder exists when run this, no files copied , hits else statement.
i tried set permissions on both folders chmod 777 avoid unix-permission errors, didnt solve issue either.
any appreciated. thank you.
i thank trying me, evidentially found way works situation , posting below in case out day fix issue (and not spend several hours trying work) - enjoy:
try: #if path exists, remove before copying copytree() if os.path.exists(dst): shutil.rmtree(dst) shutil.copytree(src, dst) except oserror e: # if error caused because source wasn't directory if e.errno == errno.enotdir: shutil.copy(source_dir_prompt, destination_dir_prompt) else: print('directory not copied. error: %s' % e)
Comments
Post a Comment