diff --git a/.vscode/settings.json b/.vscode/settings.json index 7a73a41..3012468 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,2 +1,3 @@ { + "python.pythonPath": "C:\\Apps\\Python310\\python.exe" } \ No newline at end of file diff --git a/ren_triage.py b/ren_triage.py index 03ea9ce..ee39ad9 100644 --- a/ren_triage.py +++ b/ren_triage.py @@ -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
\S*)\s?(?P.*)", 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)