initial commit

This commit is contained in:
2019-09-12 22:14:01 +02:00
parent 6baa5a6b72
commit b75a865a7c
28 changed files with 1100 additions and 0 deletions

30
set_dv_mtime.py Normal file
View File

@@ -0,0 +1,30 @@
#!python3
# set mtime for DV files from filename
# 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
import os
src = Path(r'E:\MediaByTarget\Plex\Home Videos')
author = 'ab'
dry_run = False
for raw in src.rglob("*-DV.mp4"):
mo = re.match("(?P<dt>\S*-\S*)-DV.mp4", raw.name)
if mo is None:
print(f"skipped {raw.name}, no match")
continue
md = mo.groupdict()
rawdt = dt.datetime.strptime(md['dt'],"%Y%m%d-%H%M%S")
mtime = rawdt.timestamp()
atime = raw.stat().st_atime
print(f"setting {raw.name} to {rawdt}")
os.utime(raw, (atime, mtime))