01 提取不同文件夹下同名文件
点击查看代码
def select(dir,name):
import os
import shutil
list1 =[]
list2 = []
dd = ''
for root,dirs,files in os.walk(dir):
for file in files:
# if fil.endswith():
if file == name:
list1.append(os.path.join(root,file))
list2 = list1[-1].split("\n")
for i in list2:
new = i.replace('/','_')
#print(new[2:len(new)])
dd = ''.join(new[2:len(new)])
shutil.copy(i,dd)