initial commit
This commit is contained in:
34
ren_dv_avi.py
Normal file
34
ren_dv_avi.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!python3
|
||||
|
||||
# replace avi originals by mp4
|
||||
|
||||
# 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:\MediaArchive\Andreas\RawByCamera\Sony TRV-25E')
|
||||
DRY_RUN = False
|
||||
|
||||
def rename(old, new):
|
||||
print(old.name, "->", new.name)
|
||||
if not DRY_RUN:
|
||||
if not new.exists():
|
||||
old.rename(new)
|
||||
else:
|
||||
print(f"skipped {old.name}, {new.name}, already exists")
|
||||
|
||||
for raw in src.glob("*.avi"):
|
||||
mo = re.match("ab-(?P<dat>\d{8})-(?P<title>[&\s\w]+)-(?P<tim>\d{6})-(?P<camera>[\w\s]+).avi", raw.name)
|
||||
if mo is None:
|
||||
# print(f"skipped {raw.name}, no match")
|
||||
continue
|
||||
md = mo.groupdict()
|
||||
fn = f"ab-{md['dat']}-{md['tim']}-{md['title']}-{md['camera']}{raw.suffix}"
|
||||
rename(raw, raw.parent / fn)
|
||||
Reference in New Issue
Block a user