根據圖像尺寸移動文件


#-*- coding:utf-8 -*-
from PIL import Image
import os
import shutil
source_path=r"/home/song/桌面/newtest/origin"
long_path=r"/home/song/桌面/newtest/long"
thin_path=r"/home/song/桌面/newtest/thin"
files = os.listdir(source_path)
files.sort(key=lambda x: int(x.split('.')[0]))
for file in  files:
    img = Image.open(os.path.join(source_path,file))
    width = img.size[0]
    height = img.size[1]
    if width == 480:
        shutil.move(os.path.join(source_path,file),long_path)
    if width == 321:
        shutil.move(os.path.join(source_path,file),thin_path)

 

發佈了19 篇原創文章 · 獲贊 2 · 訪問量 5546
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章