#1 2009-02-04 09:54

Markboynz
Member
Registered: 2009-02-04
Posts: 1

Multiple variables carry through

Hi there,

I'm sure this is very simple, but I am failing entirely to work it out.

I am trying to rename files that have a standard numbering system, which is s##e## where # could be any number. I want to replace those with ##x##. To make life trickier, I would ideally like to drop any preceding 0s from the first set of numbers, but keep them if they are in the second set.

Thus:
s01e01 becomes 1x01.
s01e12 becomes 1x12.
s12e12 becomes 12x12.

And just to clarify, these numbers may have other text before/after which needs to remain intact.

Any help would be gratefully appreciated!

Offline

#2 2009-02-04 10:51

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Multiple variables carry through

I suppose you mean "where # could be any digit"?

Now I'm not a RegEx guru by any stretch of the imagination wink, but I suppose the following RegEx rule should work (though there might be better ways of doing the same as well):

Expression: s0?(\d?\d)e(\d{2})

Replace: $1x$2

Offline

#3 2009-02-04 12:18

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,375

Re: Multiple variables carry through

Almost perfect, Andrew! wink

Here is a slightly improved RegEx, which will handle number sequences of any length:

Expression: s0*(\d+)e(\d+)

Replace: $1x$2

Offline

Board footer

Powered by FluxBB