python 从文件夹中提取特定图片至另一文件夹下
程序员文章站
2022-05-21 12:16:01
# -*- coding:utf8 -*-import osimport shutilclass BatchRename(): ''' 批量重命名文件夹中的图片文件 ''' def __init__(self): self.path = 'E:/check/ff' self.newpath = 'E:/check/ff1' def tiqu(self): filelist = os.listdir(self....
# -*- coding:utf8 -*-
import os
import shutil
class BatchRename():
'''
批量重命名文件夹中的图片文件
'''
def __init__(self):
self.path = 'E:/check/ff'
self.newpath = 'E:/check/ff1'
def tiqu(self):
filelist = os.listdir(self.path)
# print(filelist)
# total_num = len(filelist)
for file in filelist:
# print file
filedir = os.path.join(self.path, file)
# print filedir
(shotname, extension) = os.path.splitext(file)
# a = os.path.splitext(file)
b = shotname.split('-')[1]
# print(shotname)
if (int(b) % 15 == 1):
print (shotname)
# print(str(filedir))
shutil.copy(str(filedir), os.path.join(self.newpath, b+'.jpeg'))
if __name__ == '__main__':
demo = BatchRename()
demo.tiqu()
本文地址:https://blog.csdn.net/mndlgzzd/article/details/107356799
上一篇: 2020 7.15
下一篇: 单层GNN完成cora数据集节点分类任务