initial commit
This commit is contained in:
30
set_dv_mtime.py
Normal file
30
set_dv_mtime.py
Normal 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))
|
||||
Reference in New Issue
Block a user