# -*- coding: utf-8 -*-
"""
Created on Thu Jan 21 11:33:22 2021
根据文件名筛选将混合在同一文件夹中的图片分配到不同的文件夹中
"""
import os
import shutil
from PIL import Image
import numpy as np
path = ' /zy/task/'
newpath0=' /dataset/egg_skin/'
newpath='C: /dried_fruits_dis/'
if not os.path.exists(newpath):
os.makedirs(newpath)
filelist = os.listdir(path)
for item in filelist:
print(item)
# src = cv.imread(path1+item)
# [height,width,c]= src.shape
# img_resize1 = cv.resize(src,(int(width*0.3),int(height*0.3)),interpolation=cv.INTER_CUBIC)
name = item.split('-',3)[1]
name0=item.split('-',3)[0]
if name=='0.jpg' or name=='2.jpg'or name=='3.jpg'or name=='1.jpg':
shutil.move(path+item,newpath0)
else:
shutil.move(path+item,newpath