# Scripting with Multi value fields

**URL:** https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205
**Category:** Support
**Created:** [October 9, 2024, 4:16pm UTC](https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205 "2024-10-09T16:16:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mista\_j](https://community.mp3tag.de/user_avatar/community.mp3tag.de/mista_j/32/15808_2.png) [@mista\_j](https://community.mp3tag.de/u/mista_j)
#### Post date: [October 9, 2024, 4:16pm UTC](https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205/1 "2024-10-09T16:16:11Z")

</div>

Recently I've run into an issue where Record Labels are something like:  
Label1 / Label2 / Label3  
Label1 / Label2

The player I'm using reads those as one Record label even if I swap those "/" for commas or semicolons (which sucks)

With some scripting I changed those values listed above to these:

```auto
Label1\\Label2\\Label3
Label1\\Label2

```

With this the player reads each record label properly.

I've run into an issue though where I'm not sure how to safely script for multi value fields.

Ex:  
`$IF(%SUM TING%,T,%LABEL%)`

Here in the False clause a regular "Label" field would remain "as is" but when the field has multiple values any subsequent values after the first entry listed in the "extended tags" window are quickly thrown into the shadow realm never to be seen again. Is there a way to combat this in scripting?

For a bit more context on how I chose to approach this action sequence:

1. Using replace I changed all " / " to "/" to remove unwanted spaces in Record Labels
2. Using Guess I created two guesses for either 2 or 3 Record Labels, Each Record Label is placed into a throw away field BIN BIN1 or BIN2
3. Format Value: IF BIN2 exists then there must be 3 Labels so the field will be `BIN\\BIN1\\BIN2` IF BIN2 does not exist but BIN1 does then there must be 2 Labels, the field will be `BIN\\BIN1` & IF BIN1 does not exist then there must only be 1 label, in that case the field will be "whatever the field already is"

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 9, 2024, 4:50pm UTC](https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205/2 "2024-10-09T16:50:51Z")

</div>

> [@mista\_j](#):
>
> how to safely script for multi value fields.

If you want to get all the data as a single string, use  
$meta\_sep() with a suitable, unique separator.  
To transform that string back to multi-value fields, use `\\` as separator.

see also here:

> [@Searching (filtering) Fields with Multiple Values](https://community.mp3tag.de/t/searching-filtering-fields-with-multiple-values/66120/):
>
> I have two fields "Language 1" & "Language 2", these two fields are concatenated to form the "Language" field very simply "Language = %Language 1% %Language 2%". I can then filter files by "LANGUAGE HAS ENGLISH" for example in the filter bar. Recently I changed players so the Languages must be tagged as multi value, there must be two tags with the same name but different values in order to register properly in the music app. Now in MP3tag if I use that same expression to filter it will only ma…

---

<div class="post-metadata">

### Author: ![mista\_j](https://community.mp3tag.de/user_avatar/community.mp3tag.de/mista_j/32/15808_2.png) [@mista\_j](https://community.mp3tag.de/u/mista_j)
#### Post date: [October 9, 2024, 5:11pm UTC](https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205/3 "2024-10-09T17:11:55Z")

</div>

AHHHHHHH, that's what you meant last time. I got it working, thanks again for answering my dumb question.

---

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [October 10, 2024, 12:09am UTC](https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205/4 "2024-10-10T00:09:18Z")

</div>

> [@mista\_j](#):
>
> dumb question

Not dumb at all. I've wanted to slap myself in the head after reading this because I've used $meta\_sep() for fields in Mp3tag in the past but never thought of using it in actions.

I actually abandoned an action I had envisioned a while ago because it deleted multi-value tags during testing.  
Now I can safely use it, so your post was definitely helpful to me.

This is the action in case you're curious.

 ![grafik](https://community.mp3tag.de/uploads/default/original/3X/0/9/09fea99bbaefeda46f0678cf8ed8bd61f9290e72.png)

Action 1:  
Format value:  
Field:

```auto
ALBUMARTIST

```

Format string:

```auto

$if(%ALBUMARTIST%,$meta_sep(albumartist,\\),$if2($meta_sep(album artist,\\),$meta_sep(album_artist,\\)))

```

Action 2:  
Remove Fields:

```auto
ALBUM ARTIST;ALBUM_ARTIST

```

Explanation:

> **Summary**
>
> I dislike having different versions of the "albumartist" tag in my files, but I also don't like deleting information if it's not already present in the desired form.  
> This action keeps the ALBUMARTIST if it is present and deletes ALBUM ARTIST and ALBUM\_ARTIST tags.  
> Or if ALBUMARTIST is not present, but either ALBUM ARTIST or ALBUM\_ARTIST is (in this order), it will set ALBUMARTIST to the contents of ALBUM ARTIST or ALBUM\_ARTIST and once again deletes these 2 tags.
> 
> That way I can be sure that if there was information about the albumartist present in the source file, it will end up in the ALBUMARTIST tag and the undesired tags will be gone.
> 
> This approach is still not free of risk. If for example the ALBUMARTIST tag contains garbage and the actual information is in ALBUM ARTIST, it would be deleted and the garbage kept, but that's unlikely enough that I chose to ignore such cases. It's only a convenience action to tidy up tags before I take a look and fix things up after all.

---

<div class="post-metadata">

### Author: ![mista\_j](https://community.mp3tag.de/user_avatar/community.mp3tag.de/mista_j/32/15808_2.png) [@mista\_j](https://community.mp3tag.de/u/mista_j)
#### Post date: [October 10, 2024, 4:31am UTC](https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205/5 "2024-10-10T04:31:26Z")

</div>

This is an interesting use case as i dont often see these different tags for Album Artist. I've honestly tried avoiding multivalue tags for the same reason. I made an action & in testing it deleting info so I stuck to fields with delimiters instead. Im glad my blunder could shed light for someone.

I actually only just realized I could use scripting functions in the display colums. I just never even though to try it until learning how to use $meta\_sep.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [November 9, 2024, 4:32am UTC](https://community.mp3tag.de/t/scripting-with-multi-value-fields/66205/6 "2024-11-09T04:32:08Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
