I have a function:
def path_clone( source_dir_prompt, destination_dir_prompt) :
try:
shutil.copytree(source_dir_prompt, destination_dir_prompt)
print("Potentially copied?")
except OSError as e:
# If the error was caused because the source wasn't a directory
if e.errno == errno.ENOTDIR:
shutil.copy(source_dir_prompt, destination_dir_prompt)
else:
print('Directory not copied. Error: %s' % e)
Why is it failing and outputting :
Directory not copied. Error: [Errno 17] File exists: '[2]'
My source
directory exists with files/directory. My destination
folder exists but when i run this, no files are copied and it hits my else
statement.
I tried also to set permissions on both folders to chmod 777
to avoid unix-permission errors, but this didnt solve the issue either.
Any help is greatly appreciated. Thank you.