python实现批量copy文件到另外一个文件夹

#coding:utf-8
from xml.etree import ElementTree as ET

import os
import shutil,re

xmlpath = '/media/ymw/LANKEXIN/02facexml'
xmlnames = os.listdir(xmlpath)
i = 0
for xmlname in xmlnames:
 
    tree = ET.parse(os.path.join(xmlpath, xmlname))
    root = tree.getroot()
    small = root.getchildren()[3].getchildren()[0].getchildren()[0]
    big = root.getchildren()[3].getchildren()[0].getchildren()[1]
 

    big_xmin = int(big.getchildren()[0].text)
    big_ymin = int(big.getchildren()[1].text)
    big_xmax = int(big.getchildren()[2].text)
    big_ymax = int(big.getchildren()[3].text)
    small_xmin = int(small.getchildren()[0].text)
    small_ymin = int(small.getchildren()[1].text)
    small_xmax = int(small.getchildren()[2].text)
    small_ymax = int(small.getchildren()[3].text)
    if big_xmin > small_xmin:
        # i = i+1
        newpath = '/media/ymw/LANKEXIN/02facexml/02face_cuowu'
        shutil.copy(os.path.join(xmlpath, xmlname), newpath)

这个代码实现将02face数据集里big和face位置错误的文件的筛选。

你可能感兴趣的:(python实现批量copy文件到另外一个文件夹)