本帖最后由 949825667@qq.co 于 2016-9-9 17:56 编辑
- import os
- import shutil
- import re
- lis=open('list1.txt', 'r').read().split()
- yuan = r'C:\Users\xxxx\Desktop\求助资料\求助资料\原文件夹'
- target = r'C:\Users\xxxx\Desktop\求助资料\求助资料\目标文件夹'
- for i in os.listdir(yuan):
- inew = re.split('[\n|.]',i)[0]
- if inew in lis:
- old = os.path.join(yuan,i)
- new = os.path.join(target,i)
- lis.remove(inew)
- if os.path.isdir(old):
- if os.path.exists(new):
- pass
- else:
- shutil.copytree(old,new)
- else:
- shutil.copy(old,new)
- for s in lis:
- open('list2.txt', 'a+').write(s+'\n')
复制代码 根据你给的求助资料改的。你有时间等不如看看Python怎么用,和bat差不多! |