<div dir="ltr">If you're using Python, you could just use regular expressions to provide for the new filename.<br>For example,<div><br></div><div>pattern = r"^([A-Za-z0-9]+(?:\.[A-Za-z0-9]+)*)\.(\d{4})\..*?(\d+p)\..*\.mp4$"<br>replacement = r"\1 \2-\3.mp4"<br><br>You'd have to import re and os, of course - but then you could use a for loop to process each file.<br>For example (keeping it just to mp4s for simplicity):<br><br>def rename_movie_files(file_list):<br>    for filename in file_list:<br>        if re.match(pattern, filename):<br>            new_filename = re.sub(pattern, replacement, filename)<br>            os.rename(filename, new_filename)<br><br>movie_files = [<br>    "Zero.Dark.Thirty.2012.720p.BrRip.x264.BOKUTOX.YIFY.mp4",<br>    "The.Dark.Knight.2008.1080p.BluRay.x264.YIFY.mp4",<br>    "Inception.2010.720p.BluRay.x264.YIFY.mp4"<br>]<br><br>rename_movie_files(movie_files)</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, 1 Jan 2025 at 07:42, Ronald Barnes via kwlug-disc <<a href="mailto:kwlug-disc@kwlug.org">kwlug-disc@kwlug.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">John Driezen wrote on 2025-01-01 01:25:<br>
<br>
> newfile = movietitle+" ("+year+")-"+resolution+"."+ext<br>
<br>
You may be easier for legibility / maintenance to use "f-strings" for <br>
this formatting & concatenating, à la:<br>
<br>
 > newfile = f"{movietitle} ({year})-{resolution}.{ext}"<br>
<br>
<br>
<br>
Just a thought...<br>
<br>
<br>
_______________________________________________<br>
kwlug-disc mailing list<br>
To unsubscribe, send an email to <a href="mailto:kwlug-disc-leave@kwlug.org" target="_blank">kwlug-disc-leave@kwlug.org</a><br>
with the subject "unsubscribe", or email<br>
<a href="mailto:kwlug-disc-owner@kwlug.org" target="_blank">kwlug-disc-owner@kwlug.org</a> to contact a human being.<br>
</blockquote></div>