Partly renaming episode numbers from *-* to S**E**

A swapping-ground for Regular Expression syntax

Partly renaming episode numbers from *-* to S**E**

Postby uaeproz » Sat Apr 11, 2020 2:32 pm

Hi,

I have an old library of TV episodes but back in the day, I used to rename them like digit hyphen digit (example: 3-2) where the first digit means the season number, hyphen, second digit is the episode number.

I need to rename to be S double digits E double digits (example: from 3-2 to S03E02) but I want to keep the rest of the file description.

I would appreciate any help and guidance.

Many thanks in advance,

Abdulla
uaeproz
 
Posts: 3
Joined: Sat Apr 11, 2020 2:23 pm

Re: Partly renaming episode numbers from *-* to S**E**

Postby uaeproz » Sat Apr 11, 2020 2:35 pm

An example of exiting episode is:
1-1 Introduction.mp4

I want it to be renamed to:
s01e01 Introduction.mp4


So is the rest of the episodes in this season.
uaeproz
 
Posts: 3
Joined: Sat Apr 11, 2020 2:23 pm

Re: Partly renaming episode numbers from *-* to S**E**

Postby uaeproz » Sat Apr 11, 2020 3:31 pm

I almost figured it out so this is what I did:

Replace 1-1 with S01E01

RegMatch: (.*)(\d+)-(\d+)(.*)
RegReplace: \1S0\2E0\3\4

Replace 1-10 with S01E10

RegMatch: (.*)(\d+)-(\d+)(.*)
RegReplace: \1S0\2E\3\4


Replace 22-1 with S22E01

RegMatch: (.*)(\d{2})-(\d+)(.*)
RegReplace: \1S\2E0\3\4

Replace 22-10 with S22E10

RegMatch: (.*)(\d{2})-(\d+)(.*)
RegReplace: \1S\2E\3\4


It would be nice if the system automatically recognize single or double digits at the beginning of the file.

Many thanks for this awesome software though.
uaeproz
 
Posts: 3
Joined: Sat Apr 11, 2020 2:23 pm

Re: Partly renaming episode numbers from *-* to S**E**

Postby RegexNinja » Sat Apr 11, 2020 4:54 pm

Hi.. This replaces both single-digits in a single-run, without touching double-digits:

#1Regex Match/Replace:
^(.*)(?<!\d)(\d)-(\d)(?!\d)(.*)$
\1S0\2E0\3\4

Regex Notes:
(?<!\d) TestLeft for NOT a digit
(?!\d) TestRight for NOT a digit

Results:
1-1 Intro ----------> S01E01 Intro
Begin 3-2 ---------> Begin S03E02
Begin_1-2_End ---> Begin_S01E02_End
Begin_1-12_End --> no effect (too many digits)
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm


Return to Regular Expressions