Musicbrainz Picard scripting problem extracting surname only


Hi, I am working on my own naming script and have hit a bit of a stumbling block. I want to take the conductor name in my classical music and write it out as part of the folder name using only the last name, so for example “Herbert von Karajan” would give just “Karajan”. No matter what I try I can’t seem to make this part work and am hoping someone may be able to provide the answer to this problem. The best I’ve managed so far is to get the first name only “Hebert” by using this bit of script:

> $set(_namespace, )
> $set(aConductor:Surname,%conductor%)
> $set(aConductor:Surname,$rsearch(%aConductor:Surname%,[^%_namespace%]+%_namespace%))

Any help would be much appreciated. Please ignore the variable names as they are purely temporary until I get this doing what I want after which they’ll get replaced.


If there’s a way to extract the conductor’s sort name, that might simplify things because it would have last name first, easily separated at the comma


True, it would. Unfortunately I drew a blank on trying to work out something along those lines too. However if there is a way to do that then I could make use of a the longer method of getting the conductor sort name and then stripping it down to the surname only.


I’ve decided to stick with making the changes manually, at least for now. I still can’t figure out a way of getting the surname only and all my attempts so far end up with a blank. If anyone does know I’d still love to hear how it can be done, or even how to reverse the text which is something else I tried to do, but failed with. Perhaps I’m just trying to stretch the software too far. :wink: