Created
August 9, 2017 08:46
-
-
Save Mark24Code/250329ef6228911c2b1765ba025fab4e to your computer and use it in GitHub Desktop.
mover搬运工
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
# encoding: utf-8 | |
""" | |
搬运工Mover | |
列表一一对应,搬运文件 | |
Windows下要注意,硬盘符号要写成C:\\,Win下Unicode的问题 | |
author: mark24 | |
email: mark.zhangyoung@qq.com | |
date: 2017.08.09 | |
""" | |
import os | |
import shutil | |
fromFileSet = ['./dist/index.html', | |
'./dist/static/'] | |
toFileSet = ['./tryLib/', | |
'./target/'] | |
moveQueue = zip(fromFileSet,toFileSet) | |
for fromF, toF in moveQueue: | |
fromF = os.path.normpath(fromF) | |
toF = os.path.normpath(toF) | |
if not os.path.exists(fromF): | |
print('NotFound&Pass: {}'.format(fromF)) | |
else: | |
if not os.path.exists(toF): | |
print('mkdirs:{}'.format(toF)) | |
os.makedirs(toF) | |
else: | |
print('clear:{}'.format(toF)) | |
shutil.rmtree(toF) | |
os.makedirs(toF) | |
print("move: {} => {}".format(fromF, toF)) | |
shutil.move(fromF,toF) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment