|
45 | 45 | import threading |
46 | 46 | import multiprocessing |
47 | 47 | import shutil |
| 48 | +import glob |
48 | 49 | from PIL import Image, __version__ as pil_version |
49 | 50 | from PIL import features |
50 | 51 | from pathlib import Path |
@@ -286,25 +287,48 @@ def main(): |
286 | 287 | print(f"Pillow: {pil_version} | LibTIFF: {features.check('libtiff')}") |
287 | 288 | print(f"Deflate: {features.check('zlib')}") |
288 | 289 |
|
289 | | - input_base = Path(args.path).resolve() |
290 | | - if not input_base.exists(): sys.exit(1) |
291 | | - |
292 | | - selected_strategy = "overwrite" |
293 | | - if args.pool: selected_strategy = "pool" |
294 | | - elif args.subfolder: selected_strategy = "subfolder" |
295 | | - |
| 290 | + input_path = args.path |
| 291 | + |
| 292 | + # Expand glob patterns (Windows doesn't expand wildcards in shell) |
| 293 | + expanded_paths = glob.glob(input_path) |
| 294 | + |
296 | 295 | files_to_process = [] |
297 | | - if input_base.is_file(): |
298 | | - if input_base.suffix.lower() in ALLOWED_EXTENSIONS: files_to_process.append(input_base) |
| 296 | + |
| 297 | + if expanded_paths: |
| 298 | + # Glob matched something - process each match |
| 299 | + for p in expanded_paths: |
| 300 | + path_obj = Path(p).resolve() |
| 301 | + if path_obj.is_file() and path_obj.suffix.lower() in ALLOWED_EXTENSIONS: |
| 302 | + files_to_process.append(path_obj) |
| 303 | + elif path_obj.is_dir(): |
| 304 | + for root, _, files in os.walk(path_obj): |
| 305 | + for f in files: |
| 306 | + if f.lower().endswith(ALLOWED_EXTENSIONS): |
| 307 | + files_to_process.append(Path(root) / f) |
299 | 308 | else: |
300 | | - for root, _, files in os.walk(input_base): |
301 | | - for f in files: |
302 | | - if f.lower().endswith(ALLOWED_EXTENSIONS): files_to_process.append(Path(root) / f) |
| 309 | + # No glob match - treat as literal path |
| 310 | + input_base = Path(input_path).resolve() |
| 311 | + if not input_base.exists(): |
| 312 | + print(f"Path not found: {input_path}") |
| 313 | + sys.exit(1) |
| 314 | + |
| 315 | + if input_base.is_file(): |
| 316 | + if input_base.suffix.lower() in ALLOWED_EXTENSIONS: |
| 317 | + files_to_process.append(input_base) |
| 318 | + else: |
| 319 | + for root, _, files in os.walk(input_base): |
| 320 | + for f in files: |
| 321 | + if f.lower().endswith(ALLOWED_EXTENSIONS): |
| 322 | + files_to_process.append(Path(root) / f) |
303 | 323 |
|
304 | 324 | if not files_to_process: |
305 | 325 | print("No TIFF files found.") |
306 | 326 | return |
307 | 327 |
|
| 328 | + selected_strategy = "overwrite" |
| 329 | + if args.pool: selected_strategy = "pool" |
| 330 | + elif args.subfolder: selected_strategy = "subfolder" |
| 331 | + |
308 | 332 | sys_cores = os.cpu_count() or 1 |
309 | 333 | max_workers = int(args.jobs) if args.jobs != "auto" else sys_cores |
310 | 334 |
|
|
0 commit comments