Skip to content

Instantly share code, notes, and snippets.

@Mark24Code
Created August 9, 2017 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mark24Code/250329ef6228911c2b1765ba025fab4e to your computer and use it in GitHub Desktop.
Save Mark24Code/250329ef6228911c2b1765ba025fab4e to your computer and use it in GitHub Desktop.
mover搬运工
# 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