Skip to content

Instantly share code, notes, and snippets.

@somada141
Last active August 29, 2015 14:03
Show Gist options
  • Save somada141/fcc5e876002a712d55fd to your computer and use it in GitHub Desktop.
Save somada141/fcc5e876002a712d55fd to your computer and use it in GitHub Desktop.
How to Recursively Copy a Folder (Directory) in Python #python #fileIO #shutil
import shutil
def copyDirectory(src, dest):
try:
shutil.copytree(src, dest)
# Directories are the same
except shutil.Error as e:
print('Directory not copied. Error: %s' % e)
# Any error saying that the directory doesn't exist
except OSError as e:
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