Help with regex and logic in export options

I'm setting an export script to fill a specific html model that will be used later. I want to make 3 conditionals.

  1. If the %album% tag doesn't contain the string " - EP" or " - Single", add " [Album]" and write "%album% [Album]"

  2. If the %album% tag contains the string " - EP", replaces " - EP" with " [EP]" and write the edited album field.

  3. If the %album% tag contains the string " - Single", replaces " - Single" with " [Single]" and write the edited album field.

I started doing a pseudo code and building the code right after, but I'm struggling to understand how MP3Tag logic works:

$if( %album% has string " - EP" || " - Single", Do nothing, Concatenate and write %album% + [ALBUM] )
$if( %album% has string " - EP", Write $replace(%album%, - EP, [EP]), Do nothing )
$if( %album% has string " - Single", Write $replace(%album%, - Single, [Single]), Do nothing )

I could't move forward. Can somebody help?

You can setup a number or search/replace pairs in just one statement:, e.g.
$replace(%album%, - EP, '[Album]', - Single, '[Album]',- EP,'[EP]',- Single,'[Single]')

Hi ohrenkino, thanks for your help. I tried here and it works for EPs and Singles. But how to add "[Album]" if there is not "EP" or "Single" on it?

What about a brute force approach?
$replace(%album% '[Album]',' - EP [Album]','[EP]','- Single [Album]','[Single]')
You simply add the [Album] to every album and then you replace the special string plus the added [Album] with just the special string.

1 Like

Nice and smart approach. It worked like expected. Thank you very much for the help!