# Handling Composer in tagger scripts

**URL:** <https://community.metabrainz.org/t/handling-composer-in-tagger-scripts/557214>\
**Category:** MusicBrainz Picard\
**Tags:** scripting, taggerscript, picard\
**Created:** [October 29, 2021, 8:20am UTC](https://community.metabrainz.org/t/handling-composer-in-tagger-scripts/557214 "2021-10-29T08:20:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dj\_judas21](https://community.metabrainz.org/user_avatar/community.metabrainz.org/dj_judas21/32/15611_2.png) [@dj\_judas21](https://community.metabrainz.org/u/dj_judas21)\
**Post date:** [October 29, 2021, 8:20am UTC](https://community.metabrainz.org/t/handling-composer-in-tagger-scripts/557214/1 "2021-10-29T08:20:27Z")

</div>

Hi there. I’ve been using a Picard tagger script for ages and I’ve recently spotted a bug that I’m not sure how to solve.

I like to display the Composer field in my music player. When some recordings have a Writer but not a Composer, I want to copy Writer to Composer. But only if there is no Composer. So I’ve been using this script:

$if($not(%composer%),$if(%writer%,$copy(composer,writer)))

My problem is that if I have an MP3 file that already has some bogus tags in it (for example Composer = “banana”) and MB has no Composer, but Writer = “John Smith” then my tagger script won’t overwrite “banana” with “John Smith”.

I work around this by ticking “Clear existing tags” to get rid of bogus tags. But now if I load the MP3 into Picard the 1st time, it clears the Composer tag. If I save, quit and reload the MP3 into Picard a 2nd time, it now fills in the Composer tag from Writer. But if I load it a 3rd time, it removes the tags again!

I could simplify my script my dropping the $if() conditional, but I don’t want to unconditionally copy Writer to Composer if there is already valid data in Composer.

Is there a way to tell in tagger scripts whether a tag value has come from the MB API or whether it was read from the MP3? Thanks

---

<div class="post-metadata">

**Author:** ![yindesu](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/y/b77776/32.png) [@yindesu](https://community.metabrainz.org/u/yindesu)\
**Post date:** [October 29, 2021, 5:45pm UTC](https://community.metabrainz.org/t/handling-composer-in-tagger-scripts/557214/3 "2021-10-29T17:45:02Z")

</div>

I am pretty sure what you want to do is not possible. A possible workaround would involve moving all of your COMPOSER tags into a temporary field, so that your composer values no longer share the same field as the server’s composer values.

---

<div class="post-metadata">

**Author:** ![ernstlx](https://community.metabrainz.org/user_avatar/community.metabrainz.org/ernstlx/32/27258_2.png) [@ernstlx](https://community.metabrainz.org/u/ernstlx)\
**Post date:** [October 29, 2021, 7:26pm UTC](https://community.metabrainz.org/t/handling-composer-in-tagger-scripts/557214/4 "2021-10-29T19:26:49Z")

</div>

I haven’t fully understood:

> [@dj\_judas21](#):
>
> I work around this by ticking “Clear existing tags” to get rid of bogus tags. But now if I load the MP3 into Picard the 1st time, it clears the Composer tag. If I save, quit and reload the MP3 into Picard a 2nd time, it now fills in the Composer tag from Writer. But if I load it a 3rd time, it removes the tags again!

I suppose, you disabled “Clear existing tags” again, after you removed the bogus tags, didn’t you?  
But then the tags should not be removed…  
You like to run this script as a standard feature, every time you load new files?  
I recommend the “copymerge” function. It keeps the existing, adds what is missing without creating duplicate values.
