feat: add ' - Join' suffix stripping to strip_suffix.py
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
251b17a576
commit
9741c726bc
|
|
@ -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.mp4' -> 'video.mp4'
|
||||
'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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue