Files
board-mate/rpi/training/move_image.py
2025-12-19 06:37:19 +01:00

26 lines
778 B
Python

import os
import shutil
# ----------------------------
# Configuration
# ----------------------------
source_folder = "datasets/twhpv/valid/images"
destination_folder = "datasets/_unified/valid/images"
os.makedirs(destination_folder, exist_ok=True)
# Supported image extensions
image_extensions = [".jpg", ".jpeg", ".png", ".bmp", ".gif"]
# ----------------------------
# Copy images
# ----------------------------
for filename in os.listdir(source_folder):
if any(filename.lower().endswith(ext) for ext in image_extensions):
src_path = os.path.join(source_folder, filename)
dst_path = os.path.join(destination_folder, filename)
shutil.copy2(src_path, dst_path) # copy2 preserves metadata
print(f"All images copied to '{destination_folder}'")