Writing a list of cover art types to an image's filename?

I have this little snippet, which I’m using in the filename field of main Cover Art tab of Picard’s settings:

$if($gte(%totaldiscs%,2),
	../Artwork/
	$if($gte(%coverart_types%,2),
		%coverart_types%,
		%coverart_maintype%
	)
	$if(%coverart_comment%, 
		\(%coverart_comment%\),
	),
	Artwork/
	$if($gte(%coverart_types%,2),
		%coverart_types%,
		%coverart_maintype%
	)
	$if(%coverart_comment%, 
		\(%coverart_comment%\),
	)
)

Looking at it now I’ve realised I can simplify it a bit, but anyway…

My hopes were that should an image have two or more types, the file would be saved with these types, like back spine.jpg for example. What I’m currently getting is back.jpg and back (1).jpg, indicating that perhaps the additional types aren’t being taken into account.

Also, if this is possible, how do I go about selecting my own separator character? E.g. back, spine.jpg

1 Like

Try replacing %coverart_types% with $join(%coverart_types%,\, ), this should display multiple values as you had expected, separated by comma (needs to be escaped using a backslash) and space.
You can also drop %coverart_maintype% and the surrounding condition then, as the above line should give the same result for single values.

Originally I just wanted to show you my own image file naming script which still uses the $replace() function: $replace(%coverart_types%,; ,+) would use a plus sign as separator for multiple values.
Since $join() is a relatively new function of which I was not really aware until today, I am also posting the link to the excellent documentation as a reminder to myself and others who are still resorting to workarounds to achieve this behaviour:

https://picard-docs.musicbrainz.org/en/functions/func_join.html?highlight=join

2 Likes

How did I miss join() :see_no_evil:

$if($gte(%totaldiscs%,2),
	../Artwork/,
	Artwork/
)
$join(%coverart_types%,\, )
$if(%coverart_comment%, 
	\(%coverart_comment%\),
)

That works nicely. Thanks!