Move text after a dash into brackets at the end of the same field


I can find posts for moving text from one field to another but wish to have a field modified as such...

If a dash exists within the TITLE, (preceding or trailing SPACES are not concerned.... yet) the text after the dash is placed within parenthesis, trimmed of spaces is ideal but OK if spaces stay in as I have another script for that.

TITLE= "Thong Song - Vunzige Deuntjes Soundsystem Remix"
changes to
TITLE = Thong Song (Vunzige Deuntjes Soundsystem Remix)

I use a similar thing to remove all text after a dash.


I've tried a few variations but I can't get my text to paste back into my title.

Thanks everyone

I have found a "brute force" or "as selected only" version but it would be nice if i can do the same Conditionally.

Here's my current solution...

2024-02-02 (1)

As you can see, it just adds a bracket/parenthesis to the end in the first step, then does a simple replace of SPACE/DASH/SPACE with SPACE/parenthesis.

What should the condition be?

The condition would be...
IF %title% contains "^-^ ", ! ^ is in place of SPACE
add ")" to the end of %title%
change "^-^ " to "^(" ! ^ is in place of SPACE
DO nothing.

Thanks for asking

Try an action of the type "Format value" or Convert>Tag-Tag for TITLE
Format string: $regexp(%title%,(.*) - (.*),$1 '($2)')

That's very similar to something I tried before. I think I needed the extra "(" and ")" around variable $2 so it didn't confuse the thing.

It works.
So variable $2 HAS to be inside the quotes and the parenthesis? If I understand this right, the parenthesis are the part of the new text.

(*.) is a wild and each one creats a variable?

Thanks again

See the documentation on regular expressions:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.