Remove multiple tags on video-files

Advanced Renamer forum
#1 : 21/04-22 12:27
Claudio
Claudio
Posts: 6
Hello guys,

I'm having trouble finding the correct parameter for files below:

[SakuraCircle] Konbini Shoujo Z - 02 (DVD 720x480 h264 AAC) [C827BAB5].MKV
Need: Konbini Shoujo Z - 02.MKV

(SakuraCircle) Muttsuri Dosukebe Russia Gibo Shimai no Honshitsu Minuite Zanmai - 01 (DVD 720x480 h264 AAC) [E286056C].MKV
Need: Muttsuri Dosukebe Russia Gibo Shimai no Honshitsu Minuite Zanmai - 01.MKV

[Judas] Psycho-Pass - Movie 01 [BD 1080p][HEVC x265 10bit](Dual-Audio)[Eng-Subs].MKV
Need: Psycho-Pass - Movie 01.MKV

I want to leave only the name, remove the before and after. But there are videos that have [ ] or () before and after the name.

What would be the correct commands? I have about 500 videos this way and it will be a lot of work if you do it manually.

Thanks,

Claudio


21/04-22 12:27
#2 : 21/04-22 14:23
David Lee
David Lee
Posts: 935
We should be able to do this using a single regular expression but I can't get a Replace method to handle "[" OR "(" in the same pattern.

Rather than continue to struggle with it I suggest that you use three Replace methods...

1) Replace: "[^])]*. ?"
Occurrence: 1st

2) Replace: " ?\[.*"

3) Replace " ?\(.*"

In each case Replace with: nothing and select: "Use regular expressions".

Don't type the quotation marks in the regex.


21/04-22 14:23
#3 : 22/04-22 21:33
Claudio
Claudio
Posts: 6
Reply to #2:

THANK U VERY MUCH Sir. Its solve my problems!!

Save as default settings.



Claudio


22/04-22 21:33
#4 : 05/05-22 22:38
David in Pittsburgh
David in Pittsburgh
Posts: 1
Reply to #3:

While David Lee's reply works fine, here's another method using only one regex replacement.

1. Select a Replace method
2. Text to be replaced: [ ]*[\[\(].*?[\]\)][ ]*
(The regex is: left bracket, space, right bracket, asterisk, left bracket, backslash, left bracket, backslash, left parenthesis, right bracket, dot/period, asterisk, question mark, left bracket, backslash, right bracket, backslash, right parenthesis, right bracket,left bracket, space, right bracket, asterisk)
3. Replace with:
(Replace with is blank)
4. Occurrence: All
5. Check "Use regular expressions"

What it does in a sentence:
This regex replaces everything between either a group of brackets or parentheses and cleans up any unwanted spaces.

How it works:
When building a regex, you use brackets to define a group of matching atoms (and you use parentheses to define a matching replacement group).

The first matching group looks for leading spaces. After you remove a bracket or parenthesis section, this will clean up any extra space(s) left behind.

Thus, the first set of brackets has a space between, followed by an asterisk, '[ ]*'. This matches zero or more spaces that will precede a left bracket or left parenthesis. In your examples, there is sometimes a space between bracket and parenthesis groups and sometimes not. Thus, this will remove the leading space if it exists, e.g., between "(DVD 720x480 h264 AAC) [C827BAB5]" in #1, or do nothing when the leading space does not exist, e.g., between "[BD 1080p][HEVC x265 10bit](Dual-Audio)" in #2.

The same '[ ]*' matching group at the end of the regex will replace any trailing spaces, if they exist. For example, there is a space after the first bracket group in #1 "[SakuraCircle] ". This matching group at the end will prevent your filename from beginning with a space.

Because a set of brackets defines a matching group, when searching for bracket and parenthesis literals (i.e., searching for a bracket or parenthesis, itself), you need to escape them with a backslash '\'.

The next part of the regex, the left bracket '[' starts a matching group, the escaped left bracket '\[' searches for a literal left bracket, the escaped left parenthesis '\(' searches for a literal left parenthesis, the right bracket ']' ends the search group. In other words, this searches for the start of either a bracket or parenthesis group in the filename.

The end of the expression, '[\]\)]' is the complementary matching group. It starts with a left bracket and ends with a right bracket to define a matching group. Between the brackets are an escaped right bracket and escaped right parenthesis to match those specific characters literally. This searches for the end of either a bracket or parenthesis group in the filename.

The middle part of the expression is '.*?' - dot, asterisk, question mark. The dot in regex matches any character, the asterisk means to match that character zero or more times. Therefore, the '.*' will match anything and everything between a pair of either brackets or parentheses. HOWEVER, regex is greedy, meaning that it will match from the FIRST left bracket or parenthesis with everything between to the LAST right bracket or parenthesis, which is not what you want.

Adding the question mark to this matching will make the regex NON-GREEDY. Now, it will match everything from the FIRST left bracket or parenthesis only to the NEXT right bracket or parenthesis.

Taking the entire regex as a whole will remove anything between each individual set of brackets or parentheses and clean up any leftover spaces.

Happy matching,
David


05/05-22 22:38