From a5638e653a61ce5ec2d5eb32b39860c2c00c4e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksi=20R=C3=A4s=C3=A4nen?= Date: Sun, 19 Apr 2026 08:46:07 +0300 Subject: [PATCH] Now we take two parameters, drive to read and path to copy --- photoimport.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/photoimport.py b/photoimport.py index 408d064..9a7cd9d 100644 --- a/photoimport.py +++ b/photoimport.py @@ -34,14 +34,14 @@ def get_exif_date(file_path): def scan_photos(root_dir): """ - Recursively scans the given directory, extracts EXIF date, and prints file details. + Recursively scans the given directory (root_dir), extracts EXIF date, and prints file details. """ # Define accepted extensions (in lowercase) accepted_extensions = ( '.jpg', '.jpeg', '.dng', '.raw', '.cr2', '.cr3', '.raf' ) - print(f"--- Starting photo import scan in: {root_dir} ---") + print(f"--- Starting photo scan in: {root_dir} ---") found_files = [] # 1. Find all files @@ -87,17 +87,23 @@ def scan_photos(root_dir): if __name__ == "__main__": - # Check if a directory path argument is provided - if len(sys.argv) != 2: - print("Usage: python photoimport.py ") - print("Example (for Windows): python photoimport.py Q:\\") + # Check if two arguments are provided (script name + drive + path) + if len(sys.argv) != 3: + print("Usage: python photoimport.py ") + print("Example (for Windows): python photoimport.py Q:\\ I:\\Photos") sys.exit(1) - # The first argument (index 1) is the path - target_path = sys.argv[1] + # Argument 1: The directory to scan (the drive) + root_scan_dir = sys.argv[1] + # Argument 2: The path to display to the user + target_display_path = sys.argv[2] - # Ensure the path ends with a directory separator - if not target_path.endswith(os.sep): - target_path = target_path + os.sep + # Echo the specified path + print(f"Using path: {target_display_path}") + + # Ensure the scanning path ends with a directory separator + if not root_scan_dir.endswith(os.sep): + root_scan_dir = root_scan_dir + os.sep - scan_photos(target_path) \ No newline at end of file + # Perform the scan using the first argument (the drive) + scan_photos(root_scan_dir) \ No newline at end of file