Help with Scripting PLEASE!

Can anyone help me with this please?
Original
TITLE: Into the Lens (single version)

I would like the end result to be:
TITLE:: Into the Lens
SUBTITLE: Single Version

I know this has to be possible but I’m still figuring out the whole scripting stuff.
Any help is appreciated :slight_smile:

Assuming that the title is in the %title% tag, you could try something like this:

$set(subtitle,$rsearch(%title%,\\\(\(.*\)\\\)]*))
$if(%subtitle%,
    $set(title,$rsearch(%title%,\(^.*\)\\s\\\())
    $set(subtitle,$title(%subtitle%))
)

This will create a tag called %subtitle% containing the information in the brackets in title case. If this tag is not empty, it will modify the %title% tag to remove the portion in the brackets.

You should now be able to process the two parts separately as required.

You can get more information on the scripting functions and stuff in the documentation.

2 Likes

Thank you, thank you! I will give this a shot. Appreciate it.

2 Likes

Your suggestion so far has worked. I have come across something though that perhaps you can help me with.
There are some titles like this:
Harvest For The World (Single Version) > (Single Version) would be Subtitle
There there is this:
This Old Heart Of Mine (Is Weak For You) > These words are actually part of the title.

I thought I could do a little manual manipulation before the Picard process like anything I want to be Subtitles use Brackets instead of Parenthesis. That wouldn’t be hard for me to but I can’t for the life of me get what you sent to work. I keep getting invalid character!!

Any thoughts? Please :slight_smile:

Can you post the script that is giving you the error and I’ll see what I can find. If it’s just that you want to process the information surrounded by brackets instead of parentheses, try this:

$set(subtitle,$rsearch(%title%,\\[\(.*\)\\]]*))
$if(%subtitle%,
    $set(title,$rsearch(%title%,\(^.*\)\\s\\[))
    $set(subtitle,$title(%subtitle%))
)

I think that’s going to work!!! I work with RegEx but I can’t break this down to make any sense. In your spare time maybe you can help explain it.

Hey, you have been a tremendous help. I thank you sincerely :slight_smile:

It’s pretty much standard regular expressions except that you have to escape a backslash “\”, and the left and right parentheses “(” and “)” in order for Picard to not try to interpret them as part of the script command. In other words, for it to be interpreted as \[(.*)\].* it must be entered as \\[\(.*\)\\].*

Also I found a mistake in my earlier code. I had a closing bracket rather than a period near the end of the extraction regular expression. It still worked, but technically was incorrect. The revised version is:

$set(subtitle,$rsearch(%title%,\\[\(.*\)\\].*))
$if(%subtitle%,
    $set(title,$rsearch(%title%,\(^.*\)\\s\\[))
    $set(subtitle,$title(%subtitle%))
)

I really should add a bit of an explanation of the required escaping to the documentation.

2 Likes

Great help and explanation. Thanks!

UGHHH!! What is wrong with this? I just wanted to change the parenthesis to brackets! :frowning:

$set(Title,$replace($rreplace(%title%,(.+),),%title%,[.+])))

Caldonia Mission (live)

Probably better to use a simple $replace rather than a regular expression. Try:

$set(Title,$replace($replace(%ttitle%,\(,[),\),])))
1 Like

You make it look so easy!! :frowning: Thanks

Except I left in the change I made for my testing… It should be %title% rather than %ttitle%.

Hello. I don’t know if this could be done but you seem to have all the answers so…
Picard spits out “Release Type” as say “album; compilation”, or “album; live”


I would like to grab the second word only (compilation, or live) and ultimately that is what I would send to Helium.

Is that possible?

Have a look at the _secondaryreleasetype variable in the documentation and see if that provides what you want.

2 Likes

UGHH my head is spinning out of control :frowning:

RELEASE TYPE: album; soundtrack; live
$if(%_primaryreleasetype%,Album),$set(TESTTHIS,Single)
$if(%_primaryreleasetype%,Live),$set(TESTTHIS,Live performance)
$if(%_primaryreleasetype%,ep),$set(TESTTHIS,EP)
$if(%_primaryreleasetype%,soundtrack),$set(TESTTHIS,Sound Effects)

GIVES ME THIS?
TESTTHIS: Sound Effects

No matter what order the original Release Type is in I always get Sound Effects. I tried looking at the _secondaryreleasetype variable but that was a disaster.

I just want what is always in the second position of the original Release Type. I’ve been messing with this all day :frowning: (crying)

This is actually a simple problem… You are doing the $set() operations outside of the $if() functions, so they are always being executed.

Also, there is a problem with some of your tests. You are testing %_primaryreleasetype% in each of the tests, but it will only contain one value from the list: “album”, “single”, “ep”, “broadcast” and “other”. Testing for “live” and “soundtrack” will always fail.

The variable %_secondaryreleasetype% can contain zero or more items from the list: “audio drama”, “audiobook”, “compilation”, “demo”, “dj-mix”, “interview”, “live”, “mixtape/street”, “remix”, “soundtrack” and “spokenword”.

Because you are testing for items that could be contained in both %_primaryreleasetype% and %_secondaryreleasetype%, you might be better off testing against the %releasetype% tag, which contains the items from both the %_primaryreleasetype% and %_secondaryreleasetype% variables.

Perhaps something like:

$if($in(%releasetype%,single),$set(TESTTHIS,Single))
$if($in(%releasetype%,live),$set(TESTTHIS,Live Performance))
$if($in(%releasetype%,ep),$set(TESTTHIS,EP))
$if($in(%releasetype%,soundtrack),$set(TESTTHIS,Soundtrack))
$if($in(%releasetype%,other),$set(TESTTHIS,Sound Effects))

Note that this will only retain the setting from the latest match. If you only want one match saved, then you would do your tests in the order from least preferred (first) to most preferred (last).

If you want to match and keep more than one setting, I would do something like:

$if($in(%releasetype%,single),$set(TESTTHIS,%TESTTHIS%; Single))
$if($in(%releasetype%,live),$set(TESTTHIS,%TESTTHIS%; Live Performance))
$if($in(%releasetype%,ep),$set(TESTTHIS,%TESTTHIS%; EP))
$if($in(%releasetype%,soundtrack),$set(TESTTHIS,%TESTTHIS%; Soundtrack))
$if($in(%releasetype%,other),$set(TESTTHIS,%TESTTHIS%; Sound Effects))
$set(TESTTHIS,$trim(%TESTTHIS%,; ))

This would keep adding each match to the %TESTTHIS% tag, separating the items with a semicolon and space. The final line trims off the extra semicolon and space that would appear at the beginning of the combined %TESTTHIS% tag.

EDIT:

If I were doing something like this for myself, I would probably set the separator in a variable. That way, if I changed my mind as to what I wanted to use to separate the choices I would only need to make the change in one place rather than in every $set() statement. Something like:

$set(_separator,; )
$if($in(%releasetype%,single),$set(TESTTHIS,%TESTTHIS%%_separator%Single))
$if($in(%releasetype%,live),$set(TESTTHIS,%TESTTHIS%%_separator%Live Performance))
$if($in(%releasetype%,ep),$set(TESTTHIS,%TESTTHIS%%_separator%EP))
$if($in(%releasetype%,soundtrack),$set(TESTTHIS,%TESTTHIS%%_separator%Soundtrack))
$if($in(%releasetype%,other),$set(TESTTHIS,%TESTTHIS%%_separator%Sound Effects))
$set(TESTTHIS,$trim(%TESTTHIS%,%_separator%))
3 Likes

You ARE incredible. Not only do you help provide an answer but you so clearly explain it all.
I don’t know how to thank you enough :slight_smile:

3 Likes

I still ask a million questions (@Zas and @outsidecontext can confirm that :wink:) and I always appreciate the extra time they take to explain things. I try to do the same when I can, as a way of paying it forward. That’s what the Community is all about.

5 Likes

Hello, hope you had a good holiday!

Remember when you helped me with this? Is there anyway to tell this to look at only the last word?
If so it would save me another script action. Right now I’m converting Parens to Brackets when the title is a description like “live” which always appears at the end of the Title. “live, demo, etc. etc”
Then I run the script that you gave me above that puts that into a Subtitle.

I’m trying to cut down on clicks :frowning:
Any thoughts?

I’m not sure I understand what you’re asking. Can you provide an example or two of the input string (%title%) that you would be feeding to the function along with the corresponding output strings (%title% and %subtitle%) that you would like to see.