当前位置: 移动技术网 > IT编程>脚本编程>Python > python 从文件夹中提取特定图片至另一文件夹下

python 从文件夹中提取特定图片至另一文件夹下

2020年07月16日  | 移动技术网IT编程  | 我要评论
# -*- 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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网