#!python3 # replace avi originals by mp4 # 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 import os plex = Path(r'E:\MediaByTarget\Plex\Home Videos') rbd = Path(r"E:\MediaArchive\Andreas\RawByDate") sony = Path(r"E:\MediaArchive\Andreas\RawByCamera\Sony TRV-25E") author = 'ab' dry_run = False for mp4 in plex.rglob("*-DV.mp4"): mtime = mp4.stat().st_mtime mp4dt = dt.datetime.fromtimestamp(mtime) aviglob = f"ab-{mp4dt:%Y%m%d}*{mp4dt:%H%M%S}*Sony TRV_25E.avi" avis = list(rbd.rglob(aviglob)) if len(avis) != 1: print(f"found {len(avis)} for {aviglob}") continue avi = avis[0] # print(f"match {mp4.name} for {avi.name}") # move avi to raw Sony print(avi.name, "->", str(sony)) avi_n = sony / avi.name if not avi_n.exists(): if not dry_run: avi.rename(avi_n) else: print(f"skipped {avi.name}, {avi_n}, already exists") # move mp4 to hires mp4_fn = f"ab-{mp4dt:%Y%m%d}-{mp4dt:%H%M%S}-Sony TRV_25E.mp4" mp4_n = avi.parent / mp4_fn print(mp4.name, "->", mp4_n.name) if not mp4_n.exists(): if not dry_run: mp4.rename(mp4_n) else: print(f"skipped {mp4.name}, {mp4_n}, already exists")