akai10tsuki/mkvbatchmultiplex

RegEX bug?

VegethB opened this issue · 2 comments

image
I'm not very familiar with the world of RegEX, But for some reason, even the content after "-" is seen as part of the "Name" group.
image

Original File name: The Irregular at Magic High School - S01E01.mkv
MKVToolNix edits: The Irregular at Magic High School - S01E01.mks

RegEX: ([([].*?[])]\W*|)(?P<name>.*?)(\W*-\W*|\W*-|\W*|)(?P<episode>\d+).*
Subs: The Irregular at Magic High School - S01E\g<episode> - Owari (Kagome edit) -

WebSite used for Check: https://regex101.com/

I forgot to put the original version:

image

Screenshot 2020-10-30 141047

The regular expressions world can be quite complex. For what I understand you want a suffix appended to the destination files.

(.*) - (.*)
This regular expression will match two strings separated by "-" a hyphen with a space before and after.

\g<1> - \g<2> - Owari Kagome Edit - or
\1 - \2 - Owari Kagome Edit - or

\g<1> is equivalent to \1 both represent group 1

The substitution string where everything is literal besides \g<1> that represents group one and \g<2> representing group 2.

Screenshot 2020-10-30 142904

Here "*" the asterisk by itself is not a valid regular expression but that helps in the substitution string to assign any name using the construction <i: N> that stands for increment number by one starting with number N. This is really the easier to use without knowledge of RegEx. Also there are many many ways (ie. many RegEx's) to obtain the same results.

The RegEx that I put on the dropdowns are for the cases where the name is in the way the translation group name the episodes:

[Group Name] Series Name - Episode Number.mkv to make a substitution like Series Name - SE (Series Name - S01E01) which are media server friendly.

[Group Name] Series Name - 06.mkv -> Series Name - S01E06.mkv

These RegEx are complex because I'm trying get a pattern with as many variations as possible.

For example considering spaces there are cases.

  1. The pattern has at least one space
  2. The patter has no spaces

Screenshot 2020-10-30 144115

With group names:

Screenshot 2020-10-30 145822

Here the episodes have a title at the end again media server friendly "Name - S01E02 - Extra.mkv"

Screenshot 2020-10-30 150154

The trick is to recognize the pattern and apply the correct RegEx these ones suits my needs rarely I have to use the "*" one.

If you work with a group of patterns often with examples of current name and desired one I can help construct the RegEx for you to the best of my abilities. If they varies to much the "*" may be the way to go.

LOL! 😵🤣.
Thanks for the advice, luckily I'm not in such "drastic" situations. I usually rename with BulkRename before doing batches.


I used it for about 500 queues, no more problems 👌 (except some files that use special symbols in the name Ex: 『』)