initial commit
This commit is contained in:
45
mv_sd_mp4.py
Normal file
45
mv_sd_mp4.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#!python3
|
||||
|
||||
# https://github.com/hMatoba/Piexif
|
||||
# http://ce3wiki.theturninggate.net/doku.php?id=file_name_convention
|
||||
# destination: <BASE>/<year>/<YYYYMMDD> <Event>/ab-<YYYYMMDD>-<Event>-<nnnn>.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<dt>\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")
|
||||
|
||||
Reference in New Issue
Block a user