Now we take two parameters, drive to read and path to copy

This commit is contained in:
2026-04-19 08:46:07 +03:00
parent ba7a549f6f
commit a5638e653a
+18 -12
View File
@@ -34,14 +34,14 @@ def get_exif_date(file_path):
def scan_photos(root_dir): 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) # Define accepted extensions (in lowercase)
accepted_extensions = ( accepted_extensions = (
'.jpg', '.jpeg', '.dng', '.raw', '.cr2', '.cr3', '.raf' '.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 = [] found_files = []
# 1. Find all files # 1. Find all files
@@ -87,17 +87,23 @@ def scan_photos(root_dir):
if __name__ == "__main__": if __name__ == "__main__":
# Check if a directory path argument is provided # Check if two arguments are provided (script name + drive + path)
if len(sys.argv) != 2: if len(sys.argv) != 3:
print("Usage: python photoimport.py <drive_path>") print("Usage: python photoimport.py <drive_path> <target_display_path>")
print("Example (for Windows): python photoimport.py Q:\\") print("Example (for Windows): python photoimport.py Q:\\ I:\\Photos")
sys.exit(1) sys.exit(1)
# The first argument (index 1) is the path # Argument 1: The directory to scan (the drive)
target_path = sys.argv[1] 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 # Echo the specified path
if not target_path.endswith(os.sep): print(f"Using path: {target_display_path}")
target_path = target_path + os.sep
scan_photos(target_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
# Perform the scan using the first argument (the drive)
scan_photos(root_scan_dir)