在这里插入代码片
"""
Description:
This is scripts is used to move file from a dir to the other dir
Input:
oripath:原始文件路径
tardir: 目标文件夹
Output:
status: 1成功 0不成功
Example:
movefile(E:\demo\test.txt , D:\result)
"""
def movefile(oripath,tardir):
filename = os.path.basename(oripath)
tarpath = os.path.join(tardir, filename)
if not os.path.exists(oripath):
print('the dir is not exist:%s' % oripath)
status = 0
else:
if os.path.exists(tardir):
if os.path.exists(tarpath):
os.remove(tarpath)
else:
os.makedirs(tardir)
shutil.move(oripath, tardir)
status = 1
return status```