#!/usr/bin/python3
# encoding = utf-8
# 20220921
import glob,os,sys
import shutil
for i in open('barcod_name.txt','r', encoding="utf-8"):
if i.startswith('条形码'):
continue
else:
file = i.split('\n')[0]
barcode = file.split('\t')[0]
name = file.split('\t')[1]
path = os.getcwd()+'/results/'+'pdf/'
for root,dirs,files in os.walk(path):
for f in files:
#import pdb;pdb.set_trace()
if os.path.splitext(f)[1] =='.pdf':
if os.path.splitext(f)[0].__contains__(name):
if os.path.splitext(f)[0].__contains__(barcode[0:10]) or os.path.splitext(f)[0].__contains__(barcode):
print (os.path.basename(f))
old_filename = os.path.join(root,f)
newfile = barcode+"_"+name +'.pdf'
new_filename = os.path.join(os.path.join(os.getcwd(),'variants'),newfile)
shutil.copy(old_filename,new_filename)
运行python进行指定内容的文件名查找
最新推荐文章于 2023-06-22 04:51:06 发布