Amend export code to include total number of title entries.

Hello,

      I was very kindly helped to export a list of artists in my one folder music library:

$loop(%ARTIST%,1)$num(%_counter%,3)': '$if(%ARTIST%,$meta_sep(ARTIST,$char(13)$char(10)$repeat($char(32),5)),)
$loopend()

Is there anyone clever enough to amend this so that it also displays a total of the the number of titles by each artist after their entry please?

For example:

from

012: ABBA
013: ABC
014: AC/DC
015: Ace
016: Ace of Base

to

012: ABBA (46)
013: ABC (5)
014: AC/DC (5)
015: Ace (1)
016: Ace of Base (4)

Thanks to anyone who can help.

Try

$loop(%ARTIST%,1)$num(%_counter%,3)': '$if(%ARTIST%,$meta_sep(ARTIST,$char(13)$char(10)$repeat($char(32),5)),)$loop(%title%)$loopend() (%_max_counter%)
$loopend()
QUOTE (ohrenkino @ Aug 26 2017, 19:01) <{POST_SNAPBACK}>
Try
$loop(%ARTIST%,1)$num(%_counter%,3)': '$if(%ARTIST%,$meta_sep(ARTIST,$char(13)$char(10)$repeat($char(32),5)),)$loop(%title%)$loopend() (%_max_counter%)
$loopend()<!--QuoteEnd--></div><!--QuoteEEnd-->

That's fantastic thankyou - much appreciated.

Actually, can I take advantage of your expertise and good nature to ask a further question please?

Is it possible to get the program to display the results, putting those artists with highest number of titles first, that is (x) descending?

Thanks again.

I think that this is not possible.
The value for the (maximum) number of counts is calculated at the end of the previous loop (here: counting titles).
If the next loop starts to count the next amount of titles, the counter is reset, the value is gone.
So I would have to store the value for counts somewhere and then, when all artists and titles have been looped through, one would have to loop through all the saved counters and sort them.

But I do not see any possibility to create a list of unknown extent to save the individual counters.

If you want to have different sort criteria, I would create some kind of table with the export and use that export then in another program that can sort by columns.
You could modify the export so that in the resulting file you get the columns separated by the TAB character:
012: ABBA (46) -> 012$char(9)ABBA$char(9)46

Again, Thankyou very much.