"/Users/ace/Downloads/ass"에서 이미지 파일들을 불러와서 이미지 해상도 가로세로합이 7000보다 높으면 "/Users/ace/Downloads/무제 폴더/7000"폴더, 7000보다 낮고 5000보다 크면  "/Users/ace/Downloads/무제 폴더/5000"폴더, 5000보다 낮고 3500보다 크면 "/Users/ace/Downloads/무제 폴더/3500" 폴더로 각각 파일을 옮기는 프로그램

import os
from PIL import Image

# Set the directory where the images are located
image_dir = "/Users/ace/Downloads/ass"

# Set the destination directories
dest_7000 = "/Users/ace/Downloads/무제 폴더/7000"
dest_5000 = "/Users/ace/Downloads/무제 폴더/5000"
dest_3500 = "/Users/ace/Downloads/무제 폴더/3500"

# Iterate through the images in the directory
for filename in os.listdir(image_dir):
    # Open the image
    with Image.open(os.path.join(image_dir, filename)) as im:
        # Get the image resolution
        width, height = im.size
        
        # Check the image resolution and move the file to the appropriate directory
        if width * height > 7000 * 7000:
            os.rename(os.path.join(image_dir, filename), os.path.join(dest_7000, filename))
        elif width * height > 5000 * 5000:
            os.rename(os.path.join(image_dir, filename), os.path.join(dest_5000, filename))
        elif width * height > 3500 * 3500:
            os.rename(os.path.join(image_dir, filename), os.path.join(dest_3500, filename))

- dc official App