39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
#!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
|
|
import re
|
|
|
|
SRC = r'E:\RawByUser\Andreas\Sony TRV-25E\DV'
|
|
DEST = r'E:\VideoByDateArchive'
|
|
|
|
src = Path(SRC)
|
|
for raw in src.glob("*.avi"):
|
|
fn = raw.name
|
|
if not raw.is_file():
|
|
print(f"skipped {fn}")
|
|
continue
|
|
mo = re.match("(?P<dt>\S*\s\S*)(\s(?P<title>.*))?.avi", fn)
|
|
md = mo.groupdict()
|
|
rawdt = dt.datetime.strptime(md['dt'],"%Y-%m-%d %H.%M.%S")
|
|
title = md['title']
|
|
year = rawdt.year
|
|
day = f"{rawdt:%Y%m%d}"
|
|
ts = f"{rawdt:%H%M%S}"
|
|
destdir = Path(DEST, f"{year}",f"{day}")
|
|
if not destdir.exists():
|
|
print(f'creating {destdir}')
|
|
destdir.mkdir(parents=True)
|
|
stem = f"ab-{day}-{ts}-{title}-Sony TRV_25E"
|
|
destfn = destdir / f"{stem}{raw.suffix}"
|
|
if destfn.exists():
|
|
print(f'skipped {destfn}, already exists')
|
|
continue
|
|
print(f"{fn}", "->", destfn)
|
|
raw.rename(destfn)
|