feat: add ' - Join' suffix stripping to strip_suffix.py

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
tigerenwork 2026-05-06 00:10:08 +08:00
parent 251b17a576
commit 9741c726bc
1 changed files with 7 additions and 4 deletions

View File

@ -5,15 +5,18 @@ import glob
def strip_duplicate_suffix(filename):
"""Strips OS-generated duplicate suffixes like ' (2)', ' (3)' from a filename.
"""Strips unwanted suffixes from a filename: OS-generated ' (2)', ' (3)',
and trailing ' - Join'.
Examples:
'video (2).mp4' -> 'video.mp4'
'video (3).mp4' -> 'video.mp4'
'video - Join.mp4' -> 'video.mp4'
'video.mp4' -> 'video.mp4'
"""
name, ext = os.path.splitext(filename)
cleaned = re.sub(r'\s+\(\d+\)$', '', name)
cleaned = re.sub(r'\s+-\s+Join$', '', cleaned)
return cleaned + ext