Simple(?) but Regex is baffling to me....

A swapping-ground for Regular Expression syntax

Simple(?) but Regex is baffling to me....

Postby moriturimax » Wed May 20, 2015 2:22 am

I have several folders of files in this format, I am switching from one media server to another and the naming is slightly different..

midnightspecial.s01e01.480p.avi
or
midnightspecial.s10e01.480p.avi

I need to change it to:
midnightspecial.101.480p.avi
midnightspecial.1001.480p.avi

I've been looking at different tutorials, but my brain refuses to process the weird syntax...

If anyone could lead me to a solution I would be terribly grateful.
Thanks
moriturimax
 
Posts: 2
Joined: Wed May 20, 2015 2:16 am

Clean-up movie 'S01E02' syntax and remove leading zero

Postby Stefan » Wed May 20, 2015 6:17 am

 
FROM:
midnightspecial.s01e01.480p.avi
midnightspecial.s10e01.480p.avi
midnightspecial.s14e01.480p.avi

TO:
midnightspecial.101.480p.avi
midnightspecial.1001.480p.avi
midnightspecial.1401.480p.avi


Rule:
Remove the series 's', the episode 'e', and the leading zero from series numbering.



USE:
RegEx(1)
Match: ^(.+\.)s0?(\d+)e(\d\d)(\..+)$
Repla: \1\2\3\4


Explanation:
Match everything till a literal dot, followed by a literal 's',
followed by an zero or not, followed by one-or-more digits (1 or 10 or 14),
followed by a literal 'e', followed by two digits (01),
followed by a literal dot and the rest till the end.
Replace with what is captured into the (..) parentheses, while dropping what was not captured.


 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Simple(?) but Regex is baffling to me....

Postby moriturimax » Thu May 21, 2015 3:23 am

You are an Angel. Worked like a charm, I keep visualizing you with a giant pulsating brain...

Thanks!
moriturimax
 
Posts: 2
Joined: Wed May 20, 2015 2:16 am


Return to Regular Expressions


cron