Pad 0s in Regex

Advanced Renamer forum
#1 : 17/09-24 12:46
James E McBride
James E McBride
Posts: 17
I KNOW this should be an easy one, but I am having a tough time thinking of how to do it.

sample filenames:
1x8 - The Double Affair
1x10 - The Finny Foot Affair

My goal filename is:
S## - e## - <Episode Name>

The REPLACE method that I am currently using:
Text to be Replaced: ^(.*)(\d+)x(\d+)(.*)
Replace With: S0\2e\3 - \4

With this one, I am padding a 0 before the Season with a hard-coded '0', but I would like to change that, if possible. The value for e (Episode#) is not padded at all, and that is my goal here.....to pad both numbers to 2 integer places.

Is there a way to do this with just 1 method, or would this require some scripting?


17/09-24 12:46
#2 : 17/09-24 16:45
Delta Foxtrot
Delta Foxtrot
Posts: 285
Reply to #1:

Hi James,

You can do it with two Renumber methods.

Number positions would be 1 & 2; Relative to existing number; Number difference 0; padding manual; number length 2; apply to name.

Best,
DF


17/09-24 16:45
#3 : 17/09-24 17:56
Miguel
Miguel
Posts: 136
Reply to #1:
Hi James.

Don't think it's that easy. It's a bit tricky.
For get what you want using regex you need 2 Replace methods.
First:
REPLACE: (\d{1,2})x(\d{1})\b
REPLACE WITH: S0$1 - E0$2
Second:
REPLACE: (\d{1})x
REPLACE WITH: S0$1 - E
Check Regular expression in both methods.
This method can be used with all seasons.

And now the less complicated way. I have used this method many times.
IMPORTANT: First of all you need to make sure that the files are sorted
1x1
1x2
1x3
.
.
1x20... and so on

Will use a Replace method:
REPLACE: * -
This will remove all before the hyphen.
REPLACE WITH: S01 - E<Inc Nr:1> -
This will add the Season number and a episodes counter.
This method need change the season number. For example S02

Here is capture with my examples.
https://drive.google.com/file/d/1g_zgMzq9NsgOShW JFbNTMNURhAdyMYjo/view

Miguel

PS. Love the The Man from U.N.C.L.E series.


17/09-24 17:56 - edited 17/09-24 19:46
#4 : 17/09-24 18:48
Delta Foxtrot
Delta Foxtrot
Posts: 285
Reply to #3:

Right again, Miguel! :)

I was so focused on just the number part I didn't see the other stuff. Good catch my friend!

But on the other hand, couldn't you also add a Replace method as method #1:
Replace: ^(\d+)x
With: S$1 - e
(case sensitive, regex on)

Followed by the Renumber methods?
...

It's not a 1-method solution, but it is season and episode agnostic, and nothing is hard-coded in except the "x" (which could be replaced with any other character, of course).

It's my observation that the more specific to a small set of filenames, the less methods may be needed; on the other hand, the more generalized to a range of inputs, the more methods are needed to do exactly what is needed. But that's just a generalization in itself... :)

Best,
DF


17/09-24 18:48
#5 : 18/09-24 09:31
James E McBride
James E McBride
Posts: 17
Thank you both for your help on this!


18/09-24 09:31 - edited 18/09-24 09:37