Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4784 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a calculation field that takes a Main Genre and a Sub Genre and combines them together in a field. Because of character limitations, I like to remove any recurring instance of words that are already present in the Main Genre field, but also any repeat of of words used in Sub Genre aswell.

Example:

mainGenre = Rock

subGenre = Heavy Rock, Rock-Rap, Pop Rock, Rocktronica, Hybrid Rock, Hybrid Dramatic, Heavy Rock, Heavy Metal

combinedGenre = Rock | Heavy Rap Pop Rocktronica, Hybrid, Hybrid Dramatic, Heavy, Heavy Metal

I have been using








Let([

mainGenre = metadata_genreMain & ¶;

SubGenre = metadata_genreMainSub

];



Substitute( mainGenre; ¶ ;"") & " | " & Substitute( subGenre; [mainGenre; ""]; [¶; " "])

)



It has been working well, essentially I just added the carriage return to only pull out whole words - in the case of "Rocktronica", I would only return "tronica".

The question is, what can I add to scrub the duplicate words such as "Hybrid, Hybrid..." & "Heavy, Heavy..." after "Rock" has been removed?

Thanks,

d

Posted

You would need a custom function or a looping script to go over the list word-by-word. Are you sure this is something you really want to do, though? It seems to me that the result contains markedly less information than the input; are "character limitations" a good reason for such a thing?

Posted

Custom function or looping script would be fine. Ultimately, I am pushing these character limited fields out to AIF files' ID3 tags and then to iTunes which has a very strict character limits. While the examples given don't have a super huge list my character limit is 64 - so if I can get rid of redundant words I am able to include better more rich metadata. Also, because of the way that iTunes search works, I am able to find "Hybrid Rock" tracks even if "Hybrid" and "Rock" aren't congruent.

I will say that I have built a script that pulls data from a whole slew of calculated fields and "push" them into the appropriate target fields in iTunes. So (and I have no experience with Custom Functions) I would imagine that if pointed in the right direction, I could use this calc field (combinedGenre) as a starting point and just add some script steps during the push.

I really appreciate the help.

Thanks,

d

Posted

Wow, this works like a charm!

I would like to know what I can do to insert a separator - namley, a bar | - to separate the mainGenre from the subGenre?

Thanks again!!!

Posted

You could change the first part of the function to:

Case (



not IsEmpty ( main ) ;

CompressGenres ( RightWords ( main ; WordCount ( main ) - 1 ) ; sub ; List ( result ; LeftWords ( main ; 1 ) ; Case ( WordCount ( main ) = 1 ; "|" ) ) ) ;



not IsEmpty ( sub ) ;

...

)

Again, I am not sure how much sense this makes - given that the main genre may contain more than one word.

Posted

Why not just add this to the field calc?


Genre & "|¶" & CompressGenres ( Genre ; SubGenres ; "" )

HTH

Lee

Posted

Thanks, and this works - I will say that I am not seeing any complication with multiple word mainGenres, except that it seems to still put the | bar in when there is no subGenre. Not a big deal, I have a second calc field that strips that before the push.

But...

In the case of R&B it is removing the & symbol. I have tried fussing with it, but the only thing that I have been able to come up with is using the second calc field to replace "r b" with "R&B" - not nearly as elegant. Any tips?

Thanks,

d

Posted

Why not just add this to the field calc?

 Genre & "|¶" & CompressGenres ( Genre ; SubGenres ; "" ) 

HTH Lee

Thanks for the input. Wouldn't this cause Genre to show up twice because the Custom Function already returns the Genre?

Posted

Yes, but it appears to be doing that anyway unless I'm missing something.

BTW, the pipe character blends in too much for me, I would add a space in the Calc " |¶", or use a character like ~ (the Tilde)

Posted

it seems to still put the | bar in when there is no subGenre.

That should be a rather trivial adjustment, I think:

... Case ( WordCount ( main ) = 1 and not IsEmpty ( sub ) ; "|" ) ...

In the case of R&B it is removing the & symbol.

That's because the "&" symbol is a word delimiter, and "R&B" are two words - same as "Hip-Hop" or "Rock&Roll" are. Perhaps you could substitute it with a non-breaking character such as "ø" before sending the text to the custom function, and substitute it back to "&" in the result.

This topic is 4784 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.