Format string - make parentheses into brackets and make text within lower case

Hi all,
been screwing my head up trying to get this to work. I wonder whether doing two things at once is my problem.

My song title appears like this:
Puro Rosáceae (KMOS Harmonizer Dub)

I want it to appear like this:
Puro Rosáceae [kmos harmonizer dub]

To do this I have been using an Action with a Format String as follows: $replace($lower(%title%),'(','[',')',']')

However this results in this:
puro rosáceae [kmos harmonizer dub]

I understand why, as I'm applying the %lower to my title before doing the parentheses replacement however I can't get my head around how I target the text within the parentheses with the %lower first. I suspect I'm going about this in the wrong way.

Any help appreciated.
A

I would try it in two steps.
First use this regular expression:
$regexp(%TITLE%,(\(.*\)),\L$1)
Then in a second step, replace the brackets as you already have it (without the $lower part)

Short explanation for the regexp:
Search the first opening bracket, put everything following it until a closing bracket into a group.
Write the content of the captured group in lowercase.

You could write it with this syntax for the capturing part too:
\((.*)\)
This would not capture the brackets itself. But that doesn't matter in this case, because a bracket looks the same in normal/upper/lowercase :wink:

3 Likes

I assume by two steps you mean two separate actions? I have that working now:

Action 1 - brackets in lower case
Field: TITLE
Format String: $regexp(%TITLE%,((.*)),\L$1)

Action 2 - bracket swap
Field: TITLE
Format String: $replace(%title%,'(','[',')',']')

I'll have to be conscious what order to apply them, Action 1 then Action 2 as the other way will mean the lower case doesn't occur as the parentheses aren't seen.

Single action would've been lovely (we all love the extra milliseconds gained) but clearly too ambitious for me and I now have a workable solution! Appreciate your help!

1 Like

You could put this two actions in ONE Action Group. Then you have to care about the order to apply only once (at the moment you create the group with this two members).

Maybe the forum software has removed some chars in your $regexp format string, but you should use the \( and \) for the brackets, not only (( and ))

Yeah seems the forum modified it during copy and paste. My Action 1 has format string as per your example, with \( and \).

Regards putting them in a single action - it may be beyond my ability - I'll have a play around and try to understand how to make it work.

I'm not sure if you misunderstand my suggestion:

You can put your two single actions as they are and build an action group with them:
Press ALT + 6 then

CreateActionGroup

2 Likes

Ahhhhhhhhh! I understand you now. That makes total sense!

Thank you. Appreciate your patience. I was thinking it to be more complicated.

1 Like