Format Value action deletes multiple fields with same name


#1

Using version 2.93a.

I have an action group that cleans up field values by trimming any trailing or double spaces. When I run it on a FLAC file with multiple genres, Mp3tag loses all but the first one.

Format Value GENRE
$trim(%genre%)

My testing indicates that any Format Value action does the same thing.

Format Value GENRE
$replace(%genre%,x,y)


#2

Quick follow-up...

I installed the last version of mp3tag that I had saved - 2.91h - and it does not have this bug.


#3

The problem with this action is, that the simple placeholder %field% always refers to the first value of a possibly multi-valued field.

So in your case, $trim(%genre%) assigns the trimmed first value of the genre field to the genre field.

This probably workedTM in some cases in the past, because Mp3tag didn't apply any changes if the first value didn't change. See this entry from the changelog and the related topic for details:

FIX: action 'Format value' did not apply changes for multi-value fields if first value stayed the same. (#44428 )

An option to trim leading and trailing spaces via Format value for multiple values would be

$regexp($meta_sep(genre,'\\'),'(^|\\\\)\s+|\s+($|\\\\)',$1$2)


#4

Yes, it was probably rare that I actually had any values with trailing spaces, so the values remained the same. I discovered the problem when I added a genre to an existing album of files. I guess I'll have to rewrite those actions, or maybe just not run them any longer.

Just a hunch, but I suspect that recent change may break a lot of existing Format Value actions that users have written. You might want to think about that and see if it would be worthwhile implementing a different fix for the previous bug.