Skip to content

Instantly share code, notes, and snippets.

@liyanage
Created December 14, 2012 07:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liyanage/4283381 to your computer and use it in GitHub Desktop.
Save liyanage/4283381 to your computer and use it in GitHub Desktop.
Copy files or directories
import shutil
import os
def copy_item(source_path, destination_parent):
if os.path.isdir(source_path):
destination_path = os.path.join(destination_parent, os.path.basename(source_path))
shutil.copytree(source_path, destination_path, ignore=shutil.ignore_patterns('.DS_Store', '*.pyc'))
else:
shutil.copy(source_path, destination_parent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment