help truncating and renaming files

A swapping-ground for Regular Expression syntax

help truncating and renaming files

Postby RandmTask » Sat Mar 21, 2009 4:06 pm

Hi Im having difficulty trying to do some renaming.

What im attempting is:

-Replace "S??e??" with "??x??" where ? are numerical characters.
-Replace all dots in a filename with a space
-Eliminate everything after "??x??"

For example:
This.is.my.show.S08E06.SDTV.XviD.-=b3k=-
to:
This Is My Show 08x06

At the moment I use Replace/With to replace the dots with a space and then to replace manually s01e with s01x, s02e with 02x etc

And then use Match Replace with:
(.*)(.x)(.?)(.?)(.*)
\1\2\3\4
to get rid of everything after ??x??

Any help (with a brief explanation if you have time!) would be much appreciated.

cheers
RandmTask
 
Posts: 4
Joined: Thu Jan 12, 2006 11:39 pm

Re: help truncating and renaming files

Postby GMA » Sat Mar 21, 2009 8:22 pm

Hi, RandmTask:
Yes, you can do it all in one step:

- Set RegEx (1) as follows:

MATCH: (.*)([s,S])(\d\d)([e,E])(\d\d)(.*)
REPLACE: \1\3x\5

- Use Repl. (3) to replace dots with spaces.

- Press Rename.

----------

As for the explanation, I'm using six groups for the MATCH expression, in this order:

(.*) = Captures everything before/until the "S??E??" part.
([s,S]) = Captures both a lowercase or uppercase "s". This, along with ([e,E]), will take care of all four possible case combinations, i.e.: "s??e??", "S??E??", "S??e??" and "s??E??".
(\d\d) = A double digit.
([e,E]) = The same as ([s,S]), explained above.
(\d\d) = A double digit.
(.*) = Captures everything after the "S??E??" part.

As you know, those six groups are represented by \1\2\3\4\5\6 in the "REPLACE" box. By using "\1\3x\5", I'm saying that I want to remove groups 2, 4 and 6, and that I want to insert an "x" between groups 3 and 5 (where the "E" used to be).
Best regards,

Gabriel.
GMA
 
Posts: 91
Joined: Sun Dec 02, 2007 1:30 pm
Location: Argentina

Re: help truncating and renaming files

Postby RandmTask » Sun Mar 22, 2009 6:51 pm

Cheers Gabriel,

You've saved me a lot of work :)

Just wished Id asked this a year ago!

thanks again!
RandmTask
 
Posts: 4
Joined: Thu Jan 12, 2006 11:39 pm


Return to Regular Expressions