File Renamer (Regex)

Started by Darius1968, September 07, 2019, 09:41:51 AM

Previous topic - Next topic

Darius1968

Given:
Fantasy Island S01E08.mp4
Fantasy Island S01E09.mp4
Fantasy Island S01E14.mp4
Fantasy Island S01E15.mp4
Watch Fantasy Island S01E09 The Funny Girl Butch and Sundanc.mp4
Watch Fantasy Island S01E09 The Funny Girl Butch and Sundanc-1.mp4

With respect to Regex, this expression is common to all six file names:  E[0-9]{1,2}

All what I want to do to the six files is to append ")" to my regular expression, so that "E08" becomes equal to "E08)", "E09" becomes equal to "E09)", "E14" becomes equal to "E14)", and so forth.  How do I do this in the renamer? 

thrinn

Try
E[0-9]{1,2}[\)]?
The part between [] defines a character class containing only the closing bracket, escaped by a backslash. The question mark allows 0 or 1 brackets.
Thorsten
Win 10 / 64, IMatch 2018, IMA

Darius1968

Thorsten, that expression isn't working for me.  But, where should I enter that expression? 

thrinn

Maybe I misunderstood your question.
As you talk about the renamer, I assume you want to rename some files? Could you post an example of the original file names (as in your first post), but together with the expected resulting file names? This would be helpful.
If, for example, you want to rename
Test S01E15 SomeText.jpg
to
Test S01E15) SomeText.jpg,
you can use a "Original Filename" step followed with a "Replace Text":

Replace: E([0-9]{1,2})
With:E\1)

"Regular Expression" must be checkboxed, of course. The \1 references the first Capture Group (the part that is grabbed by the RegExp between ( and ) in the Replace expression). So, an E followed by one or to digits is replaced by E and these one or two digits, followed by the closing bracket.
Thorsten
Win 10 / 64, IMatch 2018, IMA

Darius1968

Thorsten, "E\1)" did the trick!  What I was ignorant of was the use of \# in the "With:" field, for the purpose of updating "S01E##" with "S01E##)", in the "Replace:" field.  Thanks! 

Jingo

Quote from: Darius1968 on September 07, 2019, 01:22:20 PM
Thorsten, "E\1)" did the trick!  What I was ignorant of was the use of \# in the "With:" field, for the purpose of updating "S01E##" with "S01E##)", in the "Replace:" field.  Thanks!

I always use the Regex Calculator online to learn about regex expressions... https://regex101.com -  helps explain each step and what it is doing.

thrinn

Darius,
glad to hear that it works for you now!

Andy,
thanks for the link! This site looks very helpful. I am always happy if one of my RegExp works as expected - mostly after a lot of trial & error...
Thorsten
Win 10 / 64, IMatch 2018, IMA

Jingo

You bet ... years ago I bought RegexMagic... https://www.regexmagic.com - used it to learn how to build expressions.  Now, there are websites that do similar things but regexmagic (or its big brother - RegexBuddy) is quite good still!  Enjoy!