Ad
Debugging
Image Processing
Code
Diff
  • import shutil
    import os
    
    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)
    
    • import shutil
    • import os
    • class MoveFiles:
    • def __init__(self):
    • self.images = [img for img in os.listdir('folderA') if img.endswith(('.png', '.jpg', '.jpeg'))]
    • IMAGE_FILE_EXTENSIONS = [".png", ".jpeg", ".jpg", ".svg", ".tiff", ".webp",".ppm"]
    • def move_image_files(self):
    • for img in self.images:
    • new_path = os.path.join('folderB', img)
    • shutil.move(os.path.join('folderA', img), new_path)
    • 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)