<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[REGEX: Change the name in reverse order]]></title><description><![CDATA[<p dir="auto">The names are upside down, I want to change them in ascending order. They are from 152 to 162 in the name on the hdd, but actually it was a mistake, they should have the files in the reverse order. So after replace I will have 162 instead of 151 and so on.</p>
<p dir="auto">Example:</p>
<pre><code>masini-unelte-emil-botez-carte-p1_compress_Page_151.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_152.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_153.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_154.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_155.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_156.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_157.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_158.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_159.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_160.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_161.jpg
masini-unelte-emil-botez-carte-p1_compress_Page_162.jpg
</code></pre>
<p dir="auto">So the basis would be this.<br />
FIND: <code>masini-unelte-emil-botez-carte-p1_compress_Page_\d+(.*?)\.jpg</code></p>
<p dir="auto">from here I have to select all the names and change the part of \d+ i.e. the numbers, so that I can reverse them.</p>
<p dir="auto">Output must be: <code>(162 ↔ 151; 161 ↔ 152; 160 ↔ 153...)</code></p>
<p dir="auto">I try this, but not very good:</p>
<p dir="auto">FInd: <code>_Page_(15([1-9])|16([0-2]))\.jpg</code><br />
Replace: <code>_Page_\2\3\1.jpg</code></p>
]]></description><link>https://community.notepad-plus-plus.org/topic/27640/regex-change-the-name-in-reverse-order</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 13:49:36 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/27640.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Aug 2026 07:15:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to REGEX: Change the name in reverse order on Mon, 24 Aug 2026 11:13:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gerdb42" aria-label="Profile: gerdb42">@<bdi>gerdb42</bdi></a></p>
<p dir="auto">I have over 2000 txt files, and I want to use regex. I already have a very good Python code. But I want regex. Maybe <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> knows a regex solution.</p>
<pre><code>import os
import re

FOLDER = r"g:\Colectia EMINESCIANA\tst"
PATTERN = re.compile(r"^(.*_Page_)(\d+)(\.jpg)$", re.IGNORECASE)

fisiere = []
for nume in os.listdir(FOLDER):
    m = PATTERN.match(nume)
    if m and os.path.isfile(os.path.join(FOLDER, nume)):
        fisiere.append((int(m.group(2)), nume, m.group(1), m.group(2), m.group(3)))

if not fisiere:
    raise SystemExit("Nu s-a găsit niciun fișier care să corespundă tiparului.")

fisiere.sort(key=lambda x: x[0])
numere = [f[3] for f in fisiere]
perechi = list(zip([f[1] for f in fisiere], numere[::-1]))

print(f"Se inversează {len(perechi)} fișiere din {FOLDER}\n")
for (vechi, nou_num), (_, _, prefix, _, ext) in zip(perechi, fisiere):
    print(f"  {vechi}  -&gt;  {prefix}{nou_num}{ext}")

if input("\nConfirmi redenumirea? (d/n): ").strip().lower() != "d":
    raise SystemExit("Anulat.")

temporare = []
for i, (vechi, _) in enumerate(perechi):
    tmp = f"__tmp_{i}__.jpg"
    os.rename(os.path.join(FOLDER, vechi), os.path.join(FOLDER, tmp))
    temporare.append(tmp)

for tmp, ((_, nou_num), (_, _, prefix, _, ext)) in zip(temporare, zip(perechi, fisiere)):
    os.rename(os.path.join(FOLDER, tmp), os.path.join(FOLDER, f"{prefix}{nou_num}{ext}"))

print("\nRedenumire finalizată cu succes!")
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/106171</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/106171</guid><dc:creator><![CDATA[Neculai I. Fantanaru]]></dc:creator><pubDate>Mon, 24 Aug 2026 11:13:08 GMT</pubDate></item><item><title><![CDATA[Reply to REGEX: Change the name in reverse order on Mon, 24 Aug 2026 09:05:53 GMT]]></title><description><![CDATA[<p dir="auto">So what is wrong with the sorting options from Edit-&gt;Line Operations? What are you trying to achieve that can’t be solved by them?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/106170</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/106170</guid><dc:creator><![CDATA[gerdb42]]></dc:creator><pubDate>Mon, 24 Aug 2026 09:05:53 GMT</pubDate></item></channel></rss>