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)
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):
for fp in dir.iterdir():
if fp.is_dir():
if fp.is_dir() and camera is None:
if fp.name in CAMERAS:
print(f"[{fp.name}] -------------------------------------------------")
recurse(fp, md, camera=fp.name)
elif camera:
recurse(fp, md, camera=camera)
else:
recurse(fp, md)
continue
if fp.is_dir() and camera is not None:
print(f"[{fp.name}] - [{camera}] ------------------------------------------------")
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():
print(f"{fp} neither dir nor file, skipping")
# print(f"{fp} neither dir nor file, skipping")
continue
# defaults
use_ts = True
@@ -69,6 +73,8 @@ def recurse(dir, md, camera=None):
use_camera = False
elif fp.suffix.upper() == ".MRW":
use_camera = False
elif fp.suffix.upper() == ".MPO":
use_camera = False
elif fp.suffix.upper() == ".MP4":
pass
elif fp.suffix.upper() == ".MTS":
@@ -103,17 +109,17 @@ def recurse(dir, md, camera=None):
def rename(old, new):
print(old.name, "->", new.name)
if not DRY_RUN:
if not new.exists():
old.rename(new)
if new.exists():
if old == new:
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:
print(f"skipped {old.name}, {new.name}, already exists")
old.rename(new)
for daydir in Path(SRC).iterdir():
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)
recurse(Path(SRC), None)