How to define _rating by an "if" function

Dear community
I would like to ask for some help. I try to preserve my track-rating for my music: I wrote the track-ratings into the basic tag “comment” by using a simple system: 1* / 2* / 3* / 4* / 5*
Then I transcoded my .m4a files to .FLAC. With MBPicard I want to check the metadata AND I would like to set the basic variable “_rating” by extracting the corresponding information from the basic tag “comment”.

I guess it must be something like
$set(_rating, $if(comment,—contains 1*—,1))
$set(_rating, $if(comment,—contains 2*—,2))
$set(_rating, $if(comment,—contains 3*—,3))
$set(_rating, $if(comment,—contains 4*—,4))
$set(_rating, $if(comment,—contains 5*—,5))

I might have a problem, as the “comment” tag has more information than just this and “*” is used as wildcard?

In addition I would like to set another variable based on another information from the comment field: I would like to create a variable _albumrating and set the value based on a certain key-information from the comment. Any suggestions?

Thanks for your help!

With regards

Off the top of head…

$set(_rating,
   $if($in(%comment%,1*),1)
   ,$if($in(%comment%,2*),2)
   ,$if($in(%comment%,3*),3)
   ,$if($in(%comment%,4*),4)
   ,$if($in(%comment%,5*),5)
   )))))
)
1 Like