added DJI

This commit is contained in:
Andreas Balogh
2022-05-28 20:15:40 +02:00
parent 167d42c19d
commit 219469925d
2 changed files with 24 additions and 17 deletions

View File

@@ -1,2 +1,3 @@
{ {
"python.pythonPath": "C:\\Apps\\Python310\\python.exe"
} }

View File

@@ -19,21 +19,25 @@ DRY_RUN = False
fileidx = defaultdict(int) fileidx = defaultdict(int)
CAMERAS = ("GoPro Hero3+", "Ricoh Theta V", "Ricoh Theta S", "Sony a5100", "Sony a65", "Sony TRV-25E") CAMERAS = ("GoPro Hero3+", "Ricoh Theta V", "Ricoh Theta S", "Sony a5100", "Sony a65", "Sony a68", "Sony TRV-25E", "Fuji Finepix Real 3D W3", "DJI Mini 2", "Mobile Media")
def recurse(dir, md, camera=None): def recurse(dir, md, camera=None):
for fp in dir.iterdir(): for fp in dir.iterdir():
if fp.is_dir(): if fp.is_dir() and camera is None:
if fp.name in CAMERAS: if fp.name in CAMERAS:
print(f"[{fp.name}] -------------------------------------------------")
recurse(fp, md, camera=fp.name) recurse(fp, md, camera=fp.name)
elif camera: elif camera:
recurse(fp, md, camera=camera) recurse(fp, md, camera=camera)
else: if fp.is_dir() and camera is not None:
recurse(fp, md) print(f"[{fp.name}] - [{camera}] ------------------------------------------------")
continue mo = re.match(r"(?P<dt>\S*)\s?(?P<title>.*)", fp.name)
md = mo.groupdict()
# title = md['title']
recurse(fp, md, camera=camera)
if not fp.is_file(): if not fp.is_file():
print(f"{fp} neither dir nor file, skipping") # print(f"{fp} neither dir nor file, skipping")
continue continue
# defaults # defaults
use_ts = True use_ts = True
@@ -69,6 +73,8 @@ def recurse(dir, md, camera=None):
use_camera = False use_camera = False
elif fp.suffix.upper() == ".MRW": elif fp.suffix.upper() == ".MRW":
use_camera = False use_camera = False
elif fp.suffix.upper() == ".MPO":
use_camera = False
elif fp.suffix.upper() == ".MP4": elif fp.suffix.upper() == ".MP4":
pass pass
elif fp.suffix.upper() == ".MTS": elif fp.suffix.upper() == ".MTS":
@@ -103,17 +109,17 @@ def recurse(dir, md, camera=None):
def rename(old, new): def rename(old, new):
print(old.name, "->", new.name) print(old.name, "->", new.name)
if not DRY_RUN: if not DRY_RUN:
if not new.exists(): if new.exists():
old.rename(new) if old == new:
else:
print(f"skipped {old.name}, {new.name}, already exists") print(f"skipped {old.name}, {new.name}, already exists")
else:
for c in "abcdefghijklmnopqrstuvwxyz":
alt = new.parent / f"{new.stem}{c}{new.suffix}"
if not alt.exists():
old.rename(alt)
break
else:
old.rename(new)
for daydir in Path(SRC).iterdir(): recurse(Path(SRC), None)
if not daydir.is_dir():
continue
print(f"[{daydir.name}] -------------------------------------------------")
mo = re.match(r"(?P<dt>\S*)\s?(?P<title>.*)", daydir.name)
md = mo.groupdict()
title = md['title']
recurse(daydir, md)