(argv: list[str])
| 166 | |
| 167 | |
| 168 | def main(argv: list[str]) -> int: |
| 169 | ap = argparse.ArgumentParser(description="Auto-rename photos using EXIF date (or file modified time).") |
| 170 | ap.add_argument("folder", help="Folder containing photos") |
| 171 | ap.add_argument("--recursive", action="store_true", help="Process subfolders too") |
| 172 | ap.add_argument("--dry-run", action="store_true", help="Preview changes without renaming") |
| 173 | ap.add_argument("--prefix", default="", help="Optional prefix (e.g., Japan, RWTH, Trip)") |
| 174 | ap.add_argument("--keep-original", action="store_true", |
| 175 | help="Skip files that already match YYYY-MM-DD_HH-MM-SS naming") |
| 176 | args = ap.parse_args(argv) |
| 177 | |
| 178 | folder = Path(args.folder).expanduser() |
| 179 | if not folder.exists() or not folder.is_dir(): |
| 180 | print(f"Not a directory: {folder}", file=sys.stderr) |
| 181 | return 2 |
| 182 | |
| 183 | if not PIL_OK: |
| 184 | print("[Note] Pillow not installed; EXIF dates won't be read (mtime fallback only).") |
| 185 | print(" Install for best results: pip install pillow") |
| 186 | |
| 187 | opts = Options( |
| 188 | folder=folder, |
| 189 | recursive=args.recursive, |
| 190 | dry_run=args.dry_run, |
| 191 | prefix=args.prefix, |
| 192 | keep_original=args.keep_original, |
| 193 | ) |
| 194 | rename_photos(opts) |
| 195 | return 0 |
| 196 | |
| 197 | |
| 198 | if __name__ == "__main__": |
no test coverage detected