Now we take two parameters, drive to read and path to copy
This commit is contained in:
+18
-12
@@ -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 <drive_path>")
|
||||
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 <drive_path> <target_display_path>")
|
||||
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}")
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user