Debugging
Image Processing
Nothing really different, I just don't prefer list comprehensions when they get that long.
import shutil import os IMAGE_FILE_EXTENSIONS = (".png", ".jpeg", ".jpg", ".svg", ".tiff", ".webp",".ppm") def move_image_files(source, destination): for filename in os.listdir(source): if filename.endswith(IMAGE_FILE_EXTENSIONS): old_path = os.path.join(source, filename) new_path = os.path.join(destination, filename) shutil.move(old_path, new_path)
- import shutil
- import os
IMAGE_FILE_EXTENSIONS = [".png", ".jpeg", ".jpg", ".svg", ".tiff", ".webp",".ppm"]- IMAGE_FILE_EXTENSIONS = (".png", ".jpeg", ".jpg", ".svg", ".tiff", ".webp",".ppm")
def move_image_files(source: str, target: str):for img in [img for img in os.listdir(source) if os.path.splitext(img)[-1] in IMAGE_FILE_EXTENSIONS]:new_path = os.path.join(target, img)shutil.move(os.path.join(source, img), new_path)- def move_image_files(source, destination):
- for filename in os.listdir(source):
- if filename.endswith(IMAGE_FILE_EXTENSIONS):
- old_path = os.path.join(source, filename)
- new_path = os.path.join(destination, filename)
- shutil.move(old_path, new_path)