Now we list all image files as we scan memory card

This commit is contained in:
2026-04-28 18:41:57 +03:00
parent 4f3a72b81e
commit 2443f4b954
+12
View File
@@ -40,15 +40,26 @@ def scan_photos(root_dir, base_target_path):
accepted_extensions = ('.jpg', '.jpeg', '.dng', '.raw', '.cr2', '.cr3', '.raf') accepted_extensions = ('.jpg', '.jpeg', '.dng', '.raw', '.cr2', '.cr3', '.raf')
print(f"--- Starting photo scan in: {root_dir} ---") print(f"--- Starting photo scan in: {root_dir} ---")
total_files_checked = 0
found_files = [] found_files = []
try: try:
for foldername, subfolders, filenames in os.walk(root_dir): for foldername, subfolders, filenames in os.walk(root_dir):
# Count files we are about to check in this folder
num_in_folder = len(filenames)
if num_in_folder > 0 or subfolders:
rel_folder = os.path.relpath(foldername, root_dir)
print(f" Scanning: {rel_folder} ({num_in_folder} files to check)...")
for filename in filenames: for filename in filenames:
total_files_checked += 1
full_path = os.path.join(foldername, filename) full_path = os.path.join(foldername, filename)
_, ext = os.path.splitext(filename) _, ext = os.path.splitext(filename)
if ext.lower() in accepted_extensions: if ext.lower() in accepted_extensions:
found_files.append(full_path) found_files.append(full_path)
print(f" [{len(found_files)}] {filename}")
# Progress checkpoint every 50 files checked
if total_files_checked % 50 == 0:
print(f" ...checked {total_files_checked} files, found {len(found_files)} photos so far.")
except FileNotFoundError: except FileNotFoundError:
print(f"\nFATAL ERROR: The path '{root_dir}' was not found. Please check the drive letter.") print(f"\nFATAL ERROR: The path '{root_dir}' was not found. Please check the drive letter.")
return return
@@ -56,6 +67,7 @@ def scan_photos(root_dir, base_target_path):
print(f"\nAN UNEXPECTED ERROR OCCURRED DURING DIRECTORY TRAVERSAL: {e}") print(f"\nAN UNEXPECTED ERROR OCCURRED DURING DIRECTORY TRAVERSAL: {e}")
return return
print(f" ...scan finished: checked {total_files_checked} total files.")
if not found_files: if not found_files:
print("\n--- Scan complete. No specified photo files found in this directory or its subdirectories. ---") print("\n--- Scan complete. No specified photo files found in this directory or its subdirectories. ---")
return return