Need help with a rename RegEx - A simple question I think

Hi RegEx gurus.

I have a rename script called "Fix Episode Names" to fix television episode file names. Fix capitalization, delete crap from title, etc. It works fine.

I have a separate "Season Rename" preset that renames the season number and episode number nomenclature to fix the capitalization:

Old: S22e08
New: S22E08

I have the following present for the "Season Rename" which works great:

Old Name: ^(.*)(S)(\d{2})(e)(\d{2})(.*)()$
New Name: \1S\3E\5\6

I wan to incorporate the "Season Rename" preset in to my "Fix Episode Names" script for a one-button file name fix. Right now I have to do two separate renames and it's a (very, very minor) inconvenience.

I tried:

	'-----------------------
	' Fix Season Caps
	'-----------------------

	'regex.Pattern = "^(.*)(S)(\d{2})(e)(\d{2})(.*)()$"
	'strNewName = regex.Replace(strNewName, "\1S\3E\5\6")
	

That doesn't work when I add it to my existing script. :frowning:

I have other lines in the existing script using similar code, and I used those as examples for my attempt at writing the coirrect rename RegEx. For instance, one is:

  ' Remove Periods
  regex.Pattern = "\."      
  strNameOnly = regex.Replace(strNameOnly, " ")

Can anyone tell me what I am doing wrong? I know the error is with the "regex.Pattern" portion but I don't know why it doesn't work in my existing script.

Thanks for helping. Over the years you guys (and of course, DOpus) have saved me untold hours of work. Unfortunately, I'm just not a programming whiz. What RegEx I use I have learned from this forum.

Scott
(Sarasota, FL)

Lots of information and examples here: Script to perform multiple Regular Expressions.

Hi Leo, I appreciate the link but it didn't really answer my question. The rename script you suggested is the very one I've been using as an example for creating others. But my syntax (above) does not work.

What's wrong with the syntax?

Scott

See this note towards the top of the linked article:

Since you're switching from using Opus's own regex to VBScript's, you'll need to update your pattern. Simply changing the replace pattern to $1S$3E$5$6 seems to fix it.

Ah ha! Thank you so much for the reply, Jon. That did fix it exactly.

I really appreciate your effort.

Scott