Exporting data from the highest numbered track in an album

What export script will export data from the highest numbered track in an album?

I have used $loop(%album%,1) to get just one track, but the selection seems random and I cannot see how to specify the highest numbered.

Sort or loop by TRACK ascending ... and try this ...
Determine the last loop inside loop?

DD.20140931.0840.CEST

Thanks D. That worked fine:

$filename(D:\temp\test.m3u,ANSI)$loop(%album%)$loop(%track%)$puts(CountMax,%_counter%)$loopend()$loop(%track%)$if($eql($get(CountMax),%_counter%),Album ''%album%'' last track is #%track%
,)$loopend()$loopend()

PS I see you uses a variable in a loop, a combination which was not working according to last time I tried and read reports hereabouts. Does this meet some exception criterion? Or has the bug been fixed, do you know?

The Mp3tag Export Scripting Language is an adventure playground per se.
The visibility of user defined variables ist still rather ugly.
Once a variable is defined in one loop, then it becomes visible in following loops too.
Note: Before any loop command has been invoked, the script knows some predefined system variables, %_max_counter% and others, and can immediately display their values, on scrpt level.
But within a loop %_max_counter% delivers nothing.
I was not able to "lift up" the value from %_max_counter% from script level into the loop over the files.
Therefore the first loop was needed to define a user variable to carry the needed value into the second loop.

DD.20140901.0832.CEST

Good info. Thanks.