Printable Version of Topic

Click here to view this topic in its original format

Mp3tag Forums _ Support _ Regex Required: SPACE • DOT

Posted by: ragtag Jan 11 2018, 13:09

When tagging multiple-disc albums, I usually let Mp3tag fetch the album name (or a portion thereof) from the %_directory% field, using the Format Value Action. The album name then may look something like this:

"The Ultimate Classical Album . CD1. Relax At Home"

The latter portion of the preceding album name i.e. "CD1. Relax At Home", is derived from %_directory%.

Now, I need to format this particular album field with the Mp3 tagging tools at hand, so that that the second DOT in the album field-- the one which follows directly after the CD-number, is preceded with a space. It should then look like this:

"The Ultimate Classical Album . CD1 . Relax At Home"

Could you please assist me with a regular expression, or another scripting function that will take care of this?

Your assistance is always greatly appreciated.

Posted by: stevehero Jan 11 2018, 14:21

QUOTE (ragtag @ Jan 11 2018, 13:09) *
"The Ultimate Classical Album . CD1. Relax At Home"

Breaking it down into captures.

To match The Ultimate Classical Album . CD1. Relax At Home


CODE
(?i)^(.+?[^\s])\s*\.\s*cd(\d+)\s*\.\s*(.+)



Then $1 will represent the first part
CD$2 the CD with no.
$3 the final part.

You can keep the same reg exp. Just fill in the format with section with whatever you want with either using the $1 $2 or $3.

EDIT I went a little overboard. w00t.gif

Your task can use the same expression.
CODE
(?i)^(.+?[^\s])\s*\.\s*cd(\d+)\s*\.\s*(.+)


Then use:
CODE
$1 . CD$2 . $3


In the replace with in the reg exp action.

Like I said it's overboard but you might learn something from this. But it will ensure that you've got the correct format in all your cases smile.gif

Posted by: ohrenkino Jan 11 2018, 14:23

Why don't you
replace all dots with blank-dot-blank in a first plain replace action and then
replace all double-blanks with a single blank in the next plain replace action. Done.

Posted by: ragtag Jan 11 2018, 18:41

Thank you to you both, stevehero and ohrenkino, for your quick responses.

Before I submitted my original post, I was already employing exactly the method proposed here by ohrenkino, but I thought there was an even quicker method. tongue.gif

Stevehero, I am going to experiment with your proposal as well. When you went "overboard" biggrin.gif in the beginning, it scared the wits out of me, but your final final expression may just save me step or two.

Thanks again!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)