# Tracklist For Collection Of Many Album

**URL:** https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507
**Category:** General Discussion
**Created:** [July 30, 2018, 4:03am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507 "2018-07-30T04:03:03Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![RelaxingWorld](https://community.mp3tag.de/user_avatar/community.mp3tag.de/relaxingworld/32/5532_2.png) [@RelaxingWorld](https://community.mp3tag.de/u/RelaxingWorld)
#### Post date: [July 30, 2018, 4:03am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/1 "2018-07-30T04:03:04Z")

</div>

Hello friends,  
I want to create a tracklist for the music albums:

**My script:**

```
$filename(%_folderpath%Tracklist.txt,utf-8)
$caps2(%artist% - %album%) (%year%) '['$upper(%_extension%)']'

Tracklist:
$loop(%track%)$num(%track%,2) - $caps2(%title%) ...%_length%
$loopend()

```

But has three problem and I don't know how to resolve them:

- If %Artist% has two artists in album =\> export action: Artist 1 & Artist 2  
_example: album "Guitare Latine" has 2 artists: Antonio De Lucena, Paco Nula_  
_Antonio De Lucena & Paco Nula - Guitare Latine (2014) [FLAC]_

- If %Artist% has three or more artists in album =\> export action: Various Artists  
_example: album "Natural Sound" has 4 artists: Giovanni, David Sun, Kong Xiangdong, Motoyuki Kume_  
_Various Artists - Natural Sound (2018) [FLAC]_

- I want to sort the %Year% in collection of albums like this: minYear - maxYear  
_example: Various Artists - Sounds Of The Earth (1996-2018) (40CD) [FLAC]_

Can someone help please?  
Thanks in advance!

---

<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: [July 30, 2018, 5:37am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/2 "2018-07-30T05:37:07Z")

</div>

Here is a thread about a script that deals with the range of years:

> [@Changing Tag - Filename to Range of Options?](https://community.mp3tag.de/t/changing-tag-filename-to-range-of-options/18130):
>
> Hello, apologies if this is posted somewhere, I was unable to find it. When cataloguing my audiobooks, I have Tag-Filename set up as: Artist - Series # - Title (Genre) (Bit Rate) (Format) But some (many) have varying bit-rates between files. So for example: J.K. Rowling - Harry Potter 01 - Harry Potter and the Philosopher's Stone (Fantasy) (48k) (MP3) J.K. Rowling - Harry Potter 01 - Harry Potter and the Philosopher's Stone (Fantasy) (64k) (MP3) J.K. Rowling - Harry Potter 01 - Harry Pot…

Perhaps you find something useful.

With respect to the problem of a number of artists becoming various artists: are the artists all stored in the field ARTIST or as a multi-value field ARTIST?  
Because: how do you cope with artists like "Earth, Wind & Fire", or (one of my favourites namewise) "Dave Dee, Dozy, Beaky, Mick & Tich" - these are hardly "Various Artists".

Anyway: here is an expression that counts the commas in a field:  
`"$add($len($regexp(%artist%,'[^,]',)),1)"`  
So if it adds up to more than 2 you can replace ARTIST with "Various Artists".

---

<div class="post-metadata">

### Author: ![RelaxingWorld](https://community.mp3tag.de/user_avatar/community.mp3tag.de/relaxingworld/32/5532_2.png) [@RelaxingWorld](https://community.mp3tag.de/u/RelaxingWorld)
#### Post date: [July 30, 2018, 6:48am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/3 "2018-07-30T06:48:30Z")

</div>

> [@ohrenkino](#):
>
> Here is a thread about a script that deals with the range of years:  
> [Changing Tag - Filename to Range of Options?](https://community.mp3tag.de/t/changing-tag-filename-to-range-of-options/18130)  
> Perhaps you find something useful.

Thank you!  
This problem solved.

> [@ohrenkino](#):
>
> ...here is an expression that counts the commas in a field:  
> `"$add($len($regexp(%artist%,'[^,]',)),1)"`  
> So if it adds up to more than 2 you can replace ARTIST with "Various Artists".

I tried: _"$add($len($regexp(%artist%,'[^,]',)),1)"_  
but failed!

Thanks.

---

<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: [July 30, 2018, 6:59am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/4 "2018-07-30T06:59:33Z")

</div>

> [@RelaxingWorld](#):
>
> I tried: _"$add($len($regexp(%artist%,'[^,]',)),1)"_  
> but failed!

You would have to use it as part of a $IF() statement.

---

<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: [July 30, 2018, 7:28am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/6 "2018-07-30T07:28:01Z")

</div>

Probably more like  
`$ifgreater($add($len($regexp(%artist%,'[^,]',)),1),2,Various Artists,%artist%)`

---

<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: [July 30, 2018, 8:01am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/8 "2018-07-30T08:01:08Z")

</div>

So you have  
ARTIST: Giovanni  
ARTIST: David Sun  
ARTIST: Kong Xiangdong  
ARTIST: Motoyuki Kume  
each in a separate field and not as a comma-separated list?  
I think then you have to $meta\_sep(ARTIST,, ) instead of %artist%

---

<div class="post-metadata">

### Author: ![RelaxingWorld](https://community.mp3tag.de/user_avatar/community.mp3tag.de/relaxingworld/32/5532_2.png) [@RelaxingWorld](https://community.mp3tag.de/u/RelaxingWorld)
#### Post date: [July 30, 2018, 8:03am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/9 "2018-07-30T08:03:03Z")

</div>

In my music album, each track has one artist, not comma-separated.

 ![](https://community.mp3tag.de/uploads/default/original/2X/9/9ff7e9ac27b2e439fa24a9d183872d6e0e293908.png)

---

<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: [July 30, 2018, 8:32am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/10 "2018-07-30T08:32:25Z")

</div>

As I said:

> [@RelaxingWorld](#):
>
> I think then you have to $meta\_sep(ARTIST,, ) instead of %artist%

See if this works:  
`$ifgreater($add($len($regexp( $meta_sep(ARTIST,, ),'[^,]',)),1),2,Various Artists, $meta_sep(ARTIST,, ))`

---

<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: [July 30, 2018, 9:57am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/12 "2018-07-30T09:57:25Z")

</div>

> [@RelaxingWorld](#):
>
> $ifgreater($add($len($regexp( $meta\_sep(ARTIST,, ),'[^,]',)),1),2,Various Artists, $meta\_sep(ARTIST,, ))

I was a little stingy with the apostrophes. Try  
`$ifgreater($add($len($regexp( $meta_sep(ARTIST,', '),'[^,]',)),1),2,Various Artists, $meta_sep(ARTIST,', '))`

---

<div class="post-metadata">

### Author: ![RelaxingWorld](https://community.mp3tag.de/user_avatar/community.mp3tag.de/relaxingworld/32/5532_2.png) [@RelaxingWorld](https://community.mp3tag.de/u/RelaxingWorld)
#### Post date: [July 30, 2018, 10:40am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/13 "2018-07-30T10:40:36Z")

</div>

> [@ohrenkino](#):
>
> I was a little stingy with the apostrophes. Try  
> `$ifgreater($add($len($regexp( $meta_sep(ARTIST,', '),'[^,]',)),1),2,Various Artists, $meta_sep(ARTIST,', '))`

I tried, It's still not successful...  
Thank you so much for your kind supports!

---

<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: [July 30, 2018, 10:48am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/14 "2018-07-30T10:48:47Z")

</div>

I don't understand: none of these files has several fields for ARTIST, there is always only one.

Looking at the initial post, I see that you loop by artist although you want to get first the album, then the artist.  
And as you have to determine first how many different artists there are in list of files, you would have to loop several times the artist name, increase a counter, store it and then use the result to determine what you use as summary.

---

<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: [July 30, 2018, 11:39am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/16 "2018-07-30T11:39:45Z")

</div>

Yeah, sorry: I was totally on the wrong trip.  
You can cancel everything with $meta\_sep() - this works only if you have several artists in a single file, each in a separate field (multi-value field).

So, in the part where you want to get the list of artists or "Various", try this code:  
`$loop(%artist%,1)$loopend()$put(my_art,%_max_counter%) $ifgreater($get(my_art),2,'Various',$loop(%artist%,1)%artist%, $loopend())`

---

<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: [July 30, 2018, 5:19pm UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/18 "2018-07-30T17:19:00Z")

</div>

This was a suggestion for you to play with - it should demonstrate if teh count was correct and the IF-condition worked correctly. That is why you saw the 4 (which led to "Various".  
You can suppress the output of the counter with $puts() instead of $put().

---

<div class="post-metadata">

### Author: ![RelaxingWorld](https://community.mp3tag.de/user_avatar/community.mp3tag.de/relaxingworld/32/5532_2.png) [@RelaxingWorld](https://community.mp3tag.de/u/RelaxingWorld)
#### Post date: [August 2, 2018, 1:22am UTC](https://community.mp3tag.de/t/tracklist-for-collection-of-many-album/42507/21 "2018-08-02T01:22:57Z")

</div>

@ohrenkino:  
I've combined your code with some tutorials of others in the forum...  
And finally, I got a complete script to resolve all my problems.  
Once again, thank you very much!

**Here is the my full script and I hope this will be helpful to someone:**  
_ **Tracklist For Collection Of Many Album** _

> $filename(Tracklist.txt,utf-8)$puts(ListOfArtists,%\_max\_counter%)$loop(%ARTIST%)$loop(%ALBUM%)$puts(ListOfArtists,$get(ListOfArtists)%ARTIST%', ')$loopend()$loopend()$loop(%ALBUM%)$puts(ListOfArtists,$trim($regexp($get(ListOfArtists),'(?:(?\<=,)|(?\<=\A)|(?\<=^))\s?([^,]_),(?=._?(?\<=,)\s?\1(?=,|\Z|$))(?#remove dups from comma- or comma+space- delimited list)',),', '))$loopend()$ifgreater($get(ListOfArtists),2,'Various Artists',$loop($get(ListOfArtists),1)$caps($get(ListOfArtists))$loopend())$loop(%\_filename\_ext%)$puts(ListOfExtension,$get(ListOfExtension)%\_extension%', ')$loopend()$loop(%\_extension%,1)$puts(ListOfExtension,$trim($regexp($get(ListOfExtension),'(?:(?\<=,)|(?\<=\A)|(?\<=^))\s?([^,]_),(?=._?(?\<=,)\s?\1(?=,|\Z|$))(?#remove dups from comma- or comma+space- delimited list)',),', '))$loopend()$loop(%album%)$puts(ListOfGenre,$get(ListOfGenre)%genre%', ')$loopend()$loop(%genre%,1)$puts(ListOfGenre,$trim($regexp($get(ListOfGenre),'(?:(?\<=,)|(?\<=\A)|(?\<=^))\s?([^,]_),(?=._?(?\<=,)\s?\1(?=,|\Z|$))(?#remove dups from comma- or comma+space- delimited list)',),', '))$loopend() $loop(%ALBUM%)$loop(%ALBUM%)$puts(YearMin,$if($or($less(%year%,$get(YearMin)),$less($get(YearMin),1)),%year%,$get(YearMin)))$puts(YearMax,$if($or($grtr(%year%,$get(YearMax)),$less($get(YearMax),1)),%year%,$get(YearMax)))$loopend()$loopend()- Collection ($get(YearMin)-$get(YearMax)$puts(YearMin,9999)$puts(YearMax,1)) $loop($num($regexp(%TRACK%,'^A',),1))$if($eql(1,$num($regexp(%TRACK%,'^A',),1)),$loop(%ALBUM%)$loopend()'('%\_max\_counter%'CD)',)$loopend() '['$loop($get(ListOfExtension),1)$upper($get(ListOfExtension))$loopend()']'  
> | $loop($get(ListOfExtension),1)$upper($get(ListOfExtension))$loopend() (Tracks+Cue) | %\_total\_size% | $loop($get(ListOfGenre),1)$if(%genre%,$caps($get(ListOfGenre))','$char(32)Instrumental,Instrumental)$loopend() | $loop($and($get(YearMin),$get(YearMax)),1)$get(YearMin)-$get(YearMax)$loopend() |
> 
> Albums:  
> $loop(%year%%album%,1)%year%' - '$caps(%artist%)' - '$caps2(%album%) $loop(%DISCNUMBER%,1)$ifgreater($num(%DISCNUMBER%,1),1,'('$num(%DISCNUMBER%,1)'CD)'$char(32),)$loopend()'['$upper(%\_extension%)']'  
> $loopend()  
> Tracklist:  
> $loop(%year%%album%,1)%year%' - '$caps2(%album%)' | '$upper(%\_extension%)' | '%\_total\_time%' |'$ifgreater($if2(%DISCTOTAL%,$cutLeft(%DISCNUMBER%,$strchr(%DISCNUMBER%,/))),1,  
> $loop(%DISCNUMBER%,1)'DISC '$num(%DISCNUMBER%,1)$char(13)$char(10)$loop(%track%)$num(%track%,2)' - '$caps(%artist%)' - '$caps2(%title%)' ...'%\_length%  
> $loopend()$loopend(),  
> $loop(%track%)$num(%track%,2)' - '$caps(%artist%)' - '$caps2(%title%)' ...'%\_length%  
> $loopend())  
> $loopend()'---------------'  
> 'Total playing time: '%\_total\_time%  
> 'Total size of '%\_total\_files% 'files: '%\_total\_size%

_**Example (All below information are complete automatically when export to tracklist):**_

```
Various Artists - Collection (2007-2014) (4CD) [FLAC, WAV]
| FLAC, WAV (Tracks+Cue) | 997.14 MB | Smooth Jazz, Easy Listening, Instrumental | 2007-2014 |

Albums:
2007 - Montgomery Smith - Dinner Music Vol. 1 & 2 (2CD) [FLAC]
2008 - Montgomery Smith - Careless Whisper [FLAC]
2014 - Antonio De Lucena - Alma De Guitarra [WAV]
 
Tracklist:
2007 - Dinner Music Vol. 1 & 2 | FLAC | 01:48:40 |
DISC 1
01 - Montgomery Smith - Killing Me Softly ...04:52
02 - Montgomery Smith - I'll Be There ...04:43
03 - Montgomery Smith - Let's Stay Together ...04:51
04 - Montgomery Smith - I'll Make Love To You ...04:44
05 - Montgomery Smith - For Your Love ...05:08
06 - Montgomery Smith - The First Time Ever I Saw Your Face ...04:47
07 - Montgomery Smith - How Deep Is Your Love? ...04:29
08 - Montgomery Smith - Endless Love ...05:35
09 - Montgomery Smith - Right Here Waiting ...04:28
10 - Montgomery Smith - Cherish ...04:46
11 - Montgomery Smith - The Lady In Red ...05:05
12 - Montgomery Smith - You Are So Beautiful ...03:53
DISC 2
01 - Montgomery Smith & Glendon Smith - Wonderful Tonight ...04:29
02 - Montgomery Smith & Glendon Smith - Because You Loved Me ...04:32
03 - Montgomery Smith & Glendon Smith - Love Will Keep Us Alive ...04:57
04 - Montgomery Smith & Glendon Smith - Have I Told You Lately ...04:28
05 - Montgomery Smith & Glendon Smith - Unbreak My Heart ...05:31
06 - Montgomery Smith & Glendon Smith - Whiter Shade Of Pale ...05:11
07 - Montgomery Smith & Glendon Smith - Crazy ...04:52
08 - Montgomery Smith & Glendon Smith - We're All Alone ...04:11
10 - Montgomery Smith & Glendon Smith - Suddenly ...04:53
11 - Montgomery Smith & Glendon Smith - You Don't Bring Me Flowers ...03:26
12 - Montgomery Smith & Glendon Smith - At Seventeen ...04:49

2008 - Careless Whisper | FLAC | 01:01:53 |
01 - Montgomery Smith - Crazy Love ...04:08
02 - Montgomery Smith - Do That To Me One More Time ...04:06
03 - Montgomery Smith - The Flame ...04:35
04 - Montgomery Smith - Careless Whisper ...04:53
05 - Montgomery Smith - Oh Girl ...04:33
06 - Montgomery Smith - Sailing ...04:34
07 - Montgomery Smith - How Am I Supposed To Live Without You ...04:23
08 - Montgomery Smith - Your Love Is King ...04:18
09 - Montgomery Smith - Caught Up In The Rapture ...04:59
10 - Montgomery Smith - The Power Of Love ...04:41
11 - Montgomery Smith - All I Need ...03:41
12 - Montgomery Smith - Saving All My Love For You ...03:59
13 - Montgomery Smith - I Don't Have The Heart ...04:45
14 - Montgomery Smith - The Only One For Me ...04:18

2014 - Alma De Guitarra | WAV | 00:11:40 |
01 - Antonio De Lucena - Entre Dos Aguas ...05:55
11 - Sergi Vicente - Al-Andalus ...02:30
33 - Paco Nula - Y Viva España ...03:15

--------------- 
Total playing time: 03:02:13
Total size of 40 files: 997.14 MB

```
