From 769b1115870e75c0ad02a6679e45f1e2f2cad8e4 Mon Sep 17 00:00:00 2001 From: Justin Oro Date: Wed, 26 Aug 2026 10:05:44 -0700 Subject: [PATCH] disambiguate colliding subtitle destination names instead of skipping --- plex-library-tool.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plex-library-tool.py b/plex-library-tool.py index b23f91e..7099928 100755 --- a/plex-library-tool.py +++ b/plex-library-tool.py @@ -1468,6 +1468,19 @@ def compute_consolidated_subtitle_pairs(subtitles, new_video_path): return pairs +def unique_destination(dest): + if not dest.exists(): + return dest + stem = dest.stem + ext = dest.suffix + counter = 2 + while True: + candidate = dest.parent / f"{stem} ({counter}){ext}" + if not candidate.exists(): + return candidate + counter += 1 + + def rename_consolidated_subtitles(subtitles, new_video_path, log): renamed = 0 source_dirs = set() @@ -1475,8 +1488,7 @@ def rename_consolidated_subtitles(subtitles, new_video_path, log): if dest == item: continue if dest.exists() and not same_existing_path(dest, item): - print(f"Skipping subtitle (target already exists): {item.name}") - continue + dest = unique_destination(dest) dest.parent.mkdir(exist_ok=True) source_dir = item.parent ok, err = safe_rename(item, dest)