Help with Scripting PLEASE!

Yea, this is probably not doable but I’ll explain :slight_smile:

(I want) to hear you say > This should stay as is in the title
To hear you say (live) > This should take “live” and put it in the Subtitle leaving the Title “To hear you say”

The only problem I see is that there might be some titles where the last word(s) truly need to stay as the title. Like "I want to hear you say (go away). In this case my idea won’t work.

Right now, what I’m doing (thanks to your help!) is taking something like this:
Take this away (live)
(I want to) Take this away

In the first one, I am converting the parents to Brackets [ ] to isolate that title. Then I run the script you gave me which will take the bracketed words and put in the subtitle and leave the others alone.

I’m just trying to figure out if there is a way to eliminate that two-step process. If not, I’ll just keep doing what I’m doing :slight_smile:

I think you might be able to do it for a specified list of values such as “live”, “remix”, etc. if that would help. I haven’t tested this, but maybe something like:

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

In this, you would replace “live|remix|instrumental” with the list of whatever words (case sensitive I think) that you want to extract from within parentheses at the end of the title.

That’s a good thought. I will mess around with that and see how that works.
Thanks :slight_smile:

It does create the Subtitle well but in doing so it removes the Title. I’m trying to play with all the back slashes to try and figure out why but if you see it, please let me know :frowning:
Thanks!

I think I have it! Thanks for your help as usual.

You know, in all my years of SQL work and data analysis you’d think I would get this but call me stupid because for the life of me can’t understand this :frowning:

I’m hoping that you could take one minute and break this statement down for me in plain english so I can finally comprehend this and get it!

$if($eq(encodedby,0),$set(encodedby,LAME 3.1),$set(encodedby,%encodedby%))

In this statement, what I read is in the EQ part if encodedby is equal to 0, which is not, then that is FALSE. Since that returns FALSE how does that play a part with the IF part? Does the IF statement consider FALSE to be an empty value? That is where I get all befuddled and start to pull the hair out!

If the $eq part was (encodedby,) then is what that is saying that encodedby is not equal because it’s blank?

I’m just not getting it and it’s really frustrating me cause I should get this. I’ve read, and re-read the documentation and duh!

All I’m trying to do is if the Value in the Original finding is good then I want to keep that, not overwrite it.
As in: Encoded by: Orig: AppleITunes > new: AppleITunes.

If the Encoded by: is empty then put LAME 3.1 as the New value.

Call me Stupid but I’m hoping in your way of explaining things that you could help me understand this once and for all!, Please?

Okay, I’ll try to break it down into the constituent parts.

The $if() statement takes a minimum of 2 arguments, and a maximum of 3. The first argument is the evaluation portion. Anything that returns something other than an empty string is considered True. The second part is the code to execute if the first part evaluates to something that is not blank (i.e. evaluates to True). The optional third part is the code to execute if the first part evaluates to an empty string (i.e. evaluates to False). If there is no third part provided, then nothing will be executed on a False condition.

In your case, the first part (the test) is $eq(encodedby,0). The $eq() takes two arguments and compares them (case sensitive), returning a non-empty string (I think it returns “1”) if the two arguments are equal, and an empty string if they are not equal. Remember that a non-empty string means True and an empty string means False. You are comparing the string “encodedby” to the string “0”, which evaluates to False. If you want to compare the value of a tag or variable, remember that you need to wrap it in percent signs. To get the value stored in the encodedby tag, you would use %encodedby%.

Because your example is hard coded to always return False as the condition check, it will always skip the second (True) action portion of the $if() statement, and always execute the third (False) action part. In this case, it will always set the value of the encodedby tag to the current value of the encodedby tag (essentially doing nothing).

Again that will always return false because you are comparing the string “encodedby” to an empty string. The comparison you want is $eq(%encodedby%,). In fact, an easier approach would be to just use the value of %encodedby% as the first part of the $if() statement and swap your second and third parts. That way, if the value of the encodedby tag was empty, the $if() would evaluate to False and execute the third part. If encodedby contained a value, then the second (True) part of the $if() statement would be executed.

Since you are trying to set the value of the encodedby tag to “LAME 3.1” if it is currently empty, probably the easiest way would be $set(encodedby,$if2(%encodedby%,LAME 3.1)). This sets the encodedby tag to the output of the $if2() statement. The $if2() function takes one or more arguments, and returns the first one that is not blank. In this case, if the encodedby tag is not empty, it will be used because it appears first in the list of items to check. If it is empty, then the next item “LAME 3.1” will be used because it always evaluates to non-blank.

3 Likes

This helps so much. Thank you!!!