#!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:\MediaByTarget\Plex\Home Videos') dest = Path(r'E:\MediaArchive\Andreas\RawByDate') author = 'ab' dry_run = False # def constant_factory(value): # return lambda: value # fileidx = defaultdict(constant_factory(0)) fileidx = defaultdict(int) for mp4 in src.rglob("*-SD.mp4"): mo = re.match("(?P
\S*-\S*)-SD.mp4", mp4.name) if mo is None: print(f"skipped {mp4.name}, no match") continue md = mo.groupdict() mp4dt = dt.datetime.strptime(md['dt'],"%Y%m%d-%H%M%S") # move avi to raw Sony mp4_fn = f"ab-{md['dt']}-Panasonic SDR_S7.mp4" mp4_dir = dest / str(mp4dt.year) / f"{mp4dt:%Y%m%d}" mp4_n = mp4_dir / mp4_fn if not mp4_dir.exists(): # print(f"creating {mp4_dir}") if not dry_run: mp4_dir.mkdir(parents=True) print(mp4.name, "->", mp4_n) if not mp4_n.exists(): if not dry_run: mp4.rename(mp4_n) else: print(f"skipped {mp4.name}, {mp4_n}, already exists")