python实现根据图片的名字批量转移图片到另一个文件夹

python实现根据图片的名字批量转移图片到另一个文件夹

2023年7月3日发(作者:)

python实现根据图⽚的名字批量转移图⽚到另⼀个⽂件夹python实现根据图⽚的名字将图⽚批量从⼀个⽂件夹复制到另⼀个⽂件夹import osimport shutil#按名字选取图⽚从⼀个⽂件夹到另⼀个⽂件夹⾥def getFileName(fileName): (filePath, tempFileName) = (fileName) (shotname, extension) = xt(tempFileName) return shotname,extensionsource_dir ='E:/KYY/work/youdaofeng/train/'label_dir = 'E:/KYY/电成像测井图像/分割样本/labels/60/'annotion_dir = 'E:/KYY/work/youdaofeng/label'img = r(source_dir)s=[]#遍历⽂件夹for fileNum in img: if not (fileNum): imgName = (source_dir,fileNum) #判断是否是⽂件夹,不是⽂件夹才打开 (imgPath, tempimagName) = (imgName) #将路径与⽂件名分开 (shotname,extension) = xt(tempimagName) #将⽂件名⽂本和⽂件后缀分开 #将取出来的⽂件名⽂本与特定后缀拼接,再与路径B拼接,得到B⽬录下的⽂件 tempimagName='%'%shotname imgName=(label_dir,tempimagName) #根据得到的png⽂件名,将对应⽂件拷贝到指定⽬录C (imgName,annotion_dir)

发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1688382945a129738.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信