2024-07-16 12:59:22 -06:00

13 lines
389 B
Python

#!/usr/bin/env python3
from pathlib import Path
import re
path = Path('/home/jawz/Downloads/Jubilations/485935')
pattern = re.compile(r" (\(\d{1,2}\)(?=\.\w))")
for picture in path.iterdir():
if re.search(pattern, picture.name):
newname = (re.sub(pattern, "", picture.name))
if not (path / newname).exists():
(path / picture.name).rename(path / newname)