Skip to content

Instantly share code, notes, and snippets.

@mahmudahsan
Created November 26, 2017 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmudahsan/e6c9c63a23bf4918c13fc8e2df513ebd to your computer and use it in GitHub Desktop.
Save mahmudahsan/e6c9c63a23bf4918c13fc8e2df513ebd to your computer and use it in GitHub Desktop.
import errno
import shutil
def copy(src, dest):
try:
shutil.copytree(src, dest)
except OSError as e:
# If the error was caused because the source wasn't a directory
if e.errno == errno.ENOTDIR:
shutil.copy(src, dest)
else:
print('Directory not copied. Error: %s' % e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment