Created
August 6, 2013 06:38
-
-
Save anandnalya/6162553 to your computer and use it in GitHub Desktop.
Copy file or directory in Python ref: http://stackoverflow.com/questions/1994488/copy-file-or-directory-in-python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shutil, errno | |
def copyanything(src, dst): | |
try: | |
shutil.copytree(src, dst) | |
except OSError as exc: # python >2.5 | |
if exc.errno == errno.ENOTDIR: | |
shutil.copy(src, dst) | |
else: raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment