Skip to content

Instantly share code, notes, and snippets.

@sevas
Created December 4, 2013 10:44
Show Gist options
  • Save sevas/7785611 to your computer and use it in GitHub Desktop.
Save sevas/7785611 to your computer and use it in GitHub Desktop.
a non-retarded shutil.copytree (from http://stackoverflow.com/a/13814557/40056)
def copytree(src, dst, symlinks=False, ignore=None):
if not os.path.exists(dst):
os.makedirs(dst)
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
copytree(s, d, symlinks, ignore)
else:
if not os.path.exists(d) or os.stat(src).st_mtime - os.stat(dst).st_mtime > 1:
shutil.copy2(s, d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment