# Compilation = 1 based on string content possible?

**URL:** https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119
**Category:** Mac
**Created:** [November 19, 2022, 7:40pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119 "2022-11-19T19:40:23Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![npx](https://community.mp3tag.de/user_avatar/community.mp3tag.de/npx/32/10805_2.png) [@npx](https://community.mp3tag.de/u/npx)
#### Post date: [November 19, 2022, 7:40pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/1 "2022-11-19T19:40:23Z")

</div>

I use Discogs as my main tag source on Mp3tag for Mac.  
I import the MEDIATYPE tag which, if the album is a compilation, may look for example like this:

"Vinyl (12" 33 ⅓ RPM Compilation)"  
"File (WAV Compilation)"  
"Cassette (Compilation Limited Edition)"

I would like to automatically set the id3 tag "Compilation" to "1" based on the contents of MEDIATYPE, i.e. if that string contains "Compilation", the Compilation tag is set to 1.

Is this possible? I searched but didn't find any solution here on the forums, and didn't manage to figure it out myself.

(To use Album Artist = Various does not fit my case, since some compilations are from specific artists and Various albums are not necessarily compilations.)

---

<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: [November 19, 2022, 8:00pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/2 "2022-11-19T20:00:19Z")

</div>

You could filter for all the files with the word Compilation somewhere in the tag data.  
And then assign "1" to the field COMPILATION, e.g. with the dialogue "extended tags".

---

<div class="post-metadata">

### Author: ![npx](https://community.mp3tag.de/user_avatar/community.mp3tag.de/npx/32/10805_2.png) [@npx](https://community.mp3tag.de/u/npx)
#### Post date: [November 20, 2022, 1:35pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/3 "2022-11-20T13:35:37Z")

</div>

Thank you @ohrenkino - I will use this!

Would it be possible to implement a "contains" string function for to make it possible, @Florian ? Similar to the equal function? Or would that be too resource heavy or complicated?

And another question (it is related, I think!), is it or could it be possible to pull and automatically set track number and total tracks from the tag source?

Example:

 ![track-number-total-tracks](https://community.mp3tag.de/uploads/default/original/2X/d/d5b94bbe8dc751fb8635fc8dc47403ed4e9769fc.jpeg)

Here it found the TRACK = 5, I move my file to line 5 to assign it to the correct track but if Mp3tag could read out that the album has a total of 7 tracks it might be possible for it to automatically add that at the end of the track field (i.e. "5/7" instead of just "5")? It would save a lot of time by not always having to manually set track data in the track number assistant (Cmd+K). I can see that it might mess things up a bit in some cases, but as an optional switch would be cool.

---

<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: [November 20, 2022, 1:42pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/4 "2022-11-20T13:42:47Z")

</div>

> [@npx](#):
>
> Would it be possible to implement a "contains" string function for to make it possibl

I am not sure where you want to specify the "contains".  
The filter function already has HAS as keyword - but you would have to specify where:

> [@Filtering and Searching Files and Tags](https://community.mp3tag.de/t/filtering-and-searching-files-and-tags/53271):
>
> The Filter field in Mp3tag's toolbar allows for searching files that meet a certain criteria (e.g., the filename contains specific characters or a tag field has a specific content). To filter the file list simply start typing in the filter field. As a result, all files that contain the specified filter string in their tag or filename are listed in the file list. Sometimes it is necessary to use more complex criteria to search for files (e.g., all files of a specific genre but not of that arti…

In general: the data provided by tag sources is usually beyond the control of MP3tag but relies on the community that maintains the tag source.

You can use the track numbering assistant to add the totals.  
See  
⌘ K Assign Track Numbers...

---

<div class="post-metadata">

### Author: ![npx](https://community.mp3tag.de/user_avatar/community.mp3tag.de/npx/32/10805_2.png) [@npx](https://community.mp3tag.de/u/npx)
#### Post date: [November 20, 2022, 2:20pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/5 "2022-11-20T14:20:18Z")

</div>

> I am not sure where you want to specify the "contains".  
> The filter function already has HAS as keyword

Sorry, I was unclear, I meant 'contains' as a scripting function, something like $if($contains(%mediatype%,'Compilation')$set('Compilation','1') (this syntax is surely completely broken but I hope the meaning of it is understandable. To allow full automation.

But using the filter as you suggested is a good compromise (even if it's manual it saves me a lot of time) if my idea is not possible.

> In general: the data provided by tag sources is usually beyond the control of MP3tag but relies on the community that maintains the tag source.

This I understand. I just hoped maybe it would be possible for Mp3tag to "read out" the blue marked "7" in my example even though it is not a tag field because it is the last number in the list. The Cmd-K assistant is great but does not help in my example, it only works if I tag a complete album with all tracks available. It breaks if there is one or more tracks missing.

---

<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: [November 20, 2022, 2:32pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/6 "2022-11-20T14:32:07Z")

</div>

> [@npx](#):
>
> $if($contains(%mediatype%,'Compilation')$set('Compilation','1')

See the documentation on scripting functions:

> [@Scripting Functions](https://community.mp3tag.de/t/scripting-functions/51689):
>
> Mp3tag offers various built-in scripting functions, which can be used at various places in the program. These functions offer advanced display and converting options and are to be used in combination with [Format Strings and Available Placeholders](https://community.mp3tag.de/t/format-strings-and-available-placeholders/51688). General Functions Replace $replace(string,from,to) or $replace(string,from1,to1,from2,to2,...) Example: $replace(%title%,\_,-) This example replaces all underscores with dashes. You can provide additional pairs of from/to as parameters. Case Co…

$contains would probably be $strstr()  
You would need something like  
`$ifgreater($strstr(%mediatype%,Compilation),0,1,)`

---

<div class="post-metadata">

### Author: ![npx](https://community.mp3tag.de/user_avatar/community.mp3tag.de/npx/32/10805_2.png) [@npx](https://community.mp3tag.de/u/npx)
#### Post date: [November 20, 2022, 4:47pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/7 "2022-11-20T16:47:15Z")

</div>

Wow, that seems to work perfectly! 😁

Thank you so much for the help!

---

<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: [December 20, 2022, 4:47pm UTC](https://community.mp3tag.de/t/compilation-1-based-on-string-content-possible/59119/8 "2022-12-20T16:47:47Z")

</div>

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