1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
def copytree(src, dst, symlinks=0):
names = os.listdir(src)
#os.mkdir(dst)
for name in names:
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
if symlinks and os.path.islink(srcname):
linkto = os.readlink(srcname)
os.symlink(linkto, dstname)
elif os.path.isdir(srcname):
shutil.copytree(srcname, dstname, symlinks)
else:
shutil.copy2(srcname, dstname)
except (IOError, os.error), why:
print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) |
Partager