#!python3 # https://github.com/hMatoba/Piexif # http://ce3wiki.theturninggate.net/doku.php?id=file_name_convention # destination: // /ab---.jpg from pathlib import Path import datetime as dt import piexif from collections import defaultdict import re src = Path(r'E:\MediaArchive\Andreas\RawByDate') dest = Path(r'E:\MediaArchive\Andreas\RawByCamera\Minolta Dynax 5') dry_run = False for mrw in src.rglob("*.mrw"): mo = re.match("ab-(?P
\S*-\S*).mrw", mrw.name) if mo is None: print(f"skipped {mrw.name}, no match") continue md = mo.groupdict() mrwdt = dt.datetime.strptime(md['dt'],"%Y%m%d-%H%M%S") # move avi to raw Sony mrw_dir = dest / str(mrwdt.year) / f"{mrwdt:%Y%m%d}" mrw_n = mrw_dir / mrw.name if not mrw_dir.exists(): print(f"creating {mrw_dir}") if not dry_run: mrw_dir.mkdir(parents=True) print(mrw.name, "->", mrw_n) if not mrw_n.exists(): if not dry_run: mrw.rename(mrw_n) else: print(f"skipped {mrw.name}, {mrw_n}, already exists")