INTERACT FORUM
More => Old Versions => JRiver Media Center 19 for Windows => Topic started by: Claude Lapalme on April 21, 2014, 08:31:59 am
-
Since "Find and Replace" doesn't allow the use of wildcards, I wonder if expression language could do the following:
In the Artist field, I sometimes have instruments in parentheses such as:
Peregrine Took (nose flute); Lucy Honeychurch (piano); Sam I-am (ham trombone)
Is it possible to automate the removal of the bracketed items while keeping the semicolon to have:
Peregrine Took; Lucy Honeychurch; Sam I-am
as a result?
I can't seem to find a way ...
-
It can be done with difficulty, because you have to manually code up the expression to handle some maximum number of replacements.
What is the max number of items that you have?
How many times will you be doing this operation?
Are you trying to create an expression field that does the removal?
-
Thanks for the reply, and I understand that I may dreaming ...
I was hoping to be able to plop it into the "Artist" field and hit enter, a bit like this brilliant one here to take the composer's first same and copy it to the beginning of the "Name" field:
=ifelse(!regex([Name], ^listitem([composer], 0, /,)), listitem([Composer], 0, /,):/ )[name]
A maximum would probably be 10 per track and it would be great if it worked on a selection of tracks.
-
MC lacks global substitution, so you have to do this manually by adding as many statements as you have items. For example, this handles your three-item list. Add more by duplicating the last ifelse line and incrementing the count/index numbers (in red):
listbuild(1, ;/ ,
ifelse(compare(listcount([comment]), >, 0), listitem(listitem([comment], 0), 0, / /()),
ifelse(compare(listcount([comment]), >, 1), listitem(listitem([comment], 1), 0, / /()),
ifelse(compare(listcount([comment]), >, 2), listitem(listitem([comment], 2), 0, / /())
)
One of the reasons I wrote pscriptor (http://yabb.jriver.com/interact/index.php?topic=85990.0) is that I wanted to provide a means to do this much more simply and powerfully. The limitations in the MC expression language sometimes become too great. This expression supplied to pscriptor does what you want for any number of items:
s/ \([^)]+\)//g
Example output (data is in the Comment field):
in(comment): 'Peregrine Took (nose flute); Lucy Honeychurch (piano); Sam I-am (ham trombone)'
new(comment): 'Peregrine Took; Lucy Honeychurch; Sam I-am'
-
Thank you very much for your generous help. I will experiment with this information and learn a great deal at the same time!