OLD | NEW |
1 import os | 1 import os |
2 import shutil | 2 import shutil |
3 import sys | 3 import sys |
4 | 4 |
| 5 def copyfile(src, dst): |
| 6 fsrc = None |
| 7 fdst = None |
| 8 try: |
| 9 fsrc = open(src, 'rb') |
| 10 fdst = open(dst, 'wb') |
| 11 shutil.copyfileobj(fsrc, fdst) |
| 12 finally: |
| 13 if fdst: |
| 14 fdst.close() |
| 15 if fsrc: |
| 16 fsrc.close() |
| 17 |
5 dstdir = sys.argv[1] | 18 dstdir = sys.argv[1] |
6 | 19 |
| 20 if not os.path.exists(dstdir): |
| 21 os.makedirs(dstdir) |
| 22 |
7 for i in range(2, len(sys.argv)): | 23 for i in range(2, len(sys.argv)): |
8 shutil.copy(sys.argv[i], dstdir) | 24 copyfile(sys.argv[i], os.path.join(dstdir, os.path.basename(sys.argv[i]))) |
9 | 25 |
OLD | NEW |