You still don't use the debug file, do you? You can see there every step the script does.

Well,

here is what I used in 3.9 for TRACK/TOTALTRACK.

```
outputto "title"
sayoutput "tracks"
outputto "track"
say "01/"
sayoutput "discogs pone totaltracks temp"
say "|02/"
sayoutput "discogs pone totaltracks temp"
say "|03/"
sayoutput "discogs pone totaltracks temp"
say "|04/"
sayoutput "discogs pone totaltracks temp"
say "|05/"
sayoutput "discogs pone totaltracks temp"
say "|06/"
sayoutput "discogs pone totaltracks temp"
say "|07/"
sayoutput "discogs pone totaltracks temp"
say "|08/"
sayoutput "discogs pone totaltracks temp"
say "|09/"
sayoutput "discogs pone totaltracks temp"
say "|10/"
sayoutput "discogs pone totaltracks temp"
say "|11/"
sayoutput "discogs pone totaltracks temp"
say "|12/"
sayoutput "discogs pone totaltracks temp"
say "|13/"
sayoutput "discogs pone totaltracks temp"
say "|14/"
sayoutput "discogs pone totaltracks temp"
say "|15/"
sayoutput "discogs pone totaltracks temp"
say "|16/"
sayoutput "discogs pone totaltracks temp"
say "|17/"
sayoutput "discogs pone totaltracks temp"
say "|18/"
sayoutput "discogs pone totaltracks temp"
say "|19/"
sayoutput "discogs pone totaltracks temp"
say "|20/"
sayoutput "discogs pone totaltracks temp"
say "|21/"
sayoutput "discogs pone totaltracks temp"
say "|22/"
sayoutput "discogs pone totaltracks temp"
say "|23/"
sayoutput "discogs pone totaltracks temp"
say "|24/"
sayoutput "discogs pone totaltracks temp"
say "|25/"
sayoutput "discogs pone totaltracks temp"
say "|26/"
sayoutput "discogs pone totaltracks temp"
say "|27/"
sayoutput "discogs pone totaltracks temp"
say "|28/"
sayoutput "discogs pone totaltracks temp"
say "|29/"
sayoutput "discogs pone totaltracks temp"
say "|30/"
sayoutput "discogs pone totaltracks temp"
say "|31/"
sayoutput "discogs pone totaltracks temp"
say "|32/"
sayoutput "discogs pone totaltracks temp"
say "|33/"
sayoutput "discogs pone totaltracks temp"
say "|34/"
sayoutput "discogs pone totaltracks temp"
say "|35/"
sayoutput "discogs pone totaltracks temp"
say "|36/"
sayoutput "discogs pone totaltracks temp"
say "|37/"
sayoutput "discogs pone totaltracks temp"
say "|38/"
sayoutput "discogs pone totaltracks temp"
say "|39/"
sayoutput "discogs pone totaltracks temp"
say "|40/"
sayoutput "discogs pone totaltracks temp"
say "|41/"
sayoutput "discogs pone totaltracks temp"
say "|42/"
sayoutput "discogs pone totaltracks temp"
say "|43/"
sayoutput "discogs pone totaltracks temp"
say "|44/"
sayoutput "discogs pone totaltracks temp"
say "|45/"
sayoutput "discogs pone totaltracks temp"
say "|46/"
sayoutput "discogs pone totaltracks temp"
say "|47/"
sayoutput "discogs pone totaltracks temp"
say "|48/"
sayoutput "discogs pone totaltracks temp"
say "|49/"
sayoutput "discogs pone totaltracks temp"
say "|40/"
sayoutput "discogs pone totaltracks temp"
say "|41/"
sayoutput "discogs pone totaltracks temp"
say "|42/"
sayoutput "discogs pone totaltracks temp"
say "|43/"
sayoutput "discogs pone totaltracks temp"
say "|44/"
sayoutput "discogs pone totaltracks temp"
say "|45/"
sayoutput "discogs pone totaltracks temp"
say "|46/"
sayoutput "discogs pone totaltracks temp"
say "|47/"
sayoutput "discogs pone totaltracks temp"
say "|48/"
sayoutput "discogs pone totaltracks temp"
say "|49/"
sayoutput "discogs pone totaltracks temp"
say "|60/"
sayoutput "discogs pone totaltracks temp"
say "|61/"
sayoutput "discogs pone totaltracks temp"
say "|62/"
sayoutput "discogs pone totaltracks temp"
say "|63/"
sayoutput "discogs pone totaltracks temp"
say "|64/"
sayoutput "discogs pone totaltracks temp"
say "|65/"
sayoutput "discogs pone totaltracks temp"
say "|66/"
sayoutput "discogs pone totaltracks temp"
say "|67/"
sayoutput "discogs pone totaltracks temp"
say "|68/"
sayoutput "discogs pone totaltracks temp"
say "|69/"
sayoutput "discogs pone totaltracks temp"
say "|70/"
sayoutput "discogs pone totaltracks temp"
say "|71/"
sayoutput "discogs pone totaltracks temp"
say "|72/"
sayoutput "discogs pone totaltracks temp"
say "|73/"
sayoutput "discogs pone totaltracks temp"
say "|74/"
sayoutput "discogs pone totaltracks temp"
say "|75/"
sayoutput "discogs pone totaltracks temp"
say "|76/"
sayoutput "discogs pone totaltracks temp"
say "|77/"
sayoutput "discogs pone totaltracks temp"
say "|78/"
sayoutput "discogs pone totaltracks temp"
say "|79/"
sayoutput "discogs pone totaltracks temp"
say "|80/"
sayoutput "discogs pone totaltracks temp"
say "|81/"
sayoutput "discogs pone totaltracks temp"
say "|82/"
sayoutput "discogs pone totaltracks temp"
say "|83/"
sayoutput "discogs pone totaltracks temp"
say "|84/"
sayoutput "discogs pone totaltracks temp"
say "|85/"
sayoutput "discogs pone totaltracks temp"
say "|86/"
sayoutput "discogs pone totaltracks temp"
say "|87/"
sayoutput "discogs pone totaltracks temp"
say "|88/"
sayoutput "discogs pone totaltracks temp"
say "|89/"
sayoutput "discogs pone totaltracks temp"
say "|90/"
sayoutput "discogs pone totaltracks temp"
say "|91/"
sayoutput "discogs pone totaltracks temp"
say "|92/"
sayoutput "discogs pone totaltracks temp"
say "|93/"
sayoutput "discogs pone totaltracks temp"
say "|94/"
sayoutput "discogs pone totaltracks temp"
say "|95/"
sayoutput "discogs pone totaltracks temp"
say "|96/"
sayoutput "discogs pone totaltracks temp"
say "|97/"
sayoutput "discogs pone totaltracks temp"
say "|98/"
sayoutput "discogs pone totaltracks temp"
say "|99/"
sayoutput "discogs pone totaltracks temp"
say "|"
set "discogs pone totaltracks temp"
```

As you can see, it works only for a maximum of 99 tracks, but you can extend it as long as you like. It works with the same logic as the say "01|02|03|04|05|06|07|08|09|" solution in the other topic.

For the more complicated way I'm using now, here is the code:

```
# TRACK COUNTER
gotoline 3
findline "Tracklist</span>"
findline "<table"
joinuntil "</table>"
regexpreplace "class=\"track_pos\"" " <<<Track>>>I<<<Track>>> "
regexpreplace ".*?(<<<Track>>>.*<<<Track>>>).*" "$1"
regexpreplace "<<<Track>>>[^I].*?<<<Track>>>" "<<<Track>>>"
replace "<<<Track>>>" ""
do # get seperated tracknumbers
regexpreplace "^(I)(I+)" "$2|$1$2"
findinline "I"
while "I"
unspace
replace "IIIIIIIIII" "X"
replace "XXXXXXXXXX" "C"
replace "CI" "C0I"
regexpreplace "X($|\|)" "X0$1"
regexpreplace "C($|\|)" "C00$1"
replace "CCCCCCCCC" "9"
replace "CCCCCCCC" "8"
replace "CCCCCCC" "7"
replace "CCCCCC" "6"
replace "CCCCC" "5"
replace "CCCC" "4"
replace "CCC" "3"
replace "CC" "2"
replace "C" "1"
replace "XXXXXXXXX" "9"
replace "XXXXXXXX" "8"
replace "XXXXXXX" "7"
replace "XXXXXX" "6"
replace "XXXXX" "5"
replace "XXXX" "4"
replace "XXX" "3"
replace "XX" "2"
replace "X" "1"
replace "IIIIIIIII" "9"
replace "IIIIIIII" "8"
replace "IIIIIII" "7"
replace "IIIIII" "6"
replace "IIIII" "5"
replace "IIII" "4"
replace "III" "3"
replace "II" "2"
replace "I" "1"
# DISCOGS~TRACK NUMBER / TOTALTRACKS
outputto "discogs pone track / totaltracks temp"
sayuntil "|"
say "/"
sayregexp "(\d+)$"
do
say "|"
movechar 1
sayuntil "|"
say "/"
sayregexp "(\d+)$"
while "|" 30
unspace
sayregexp "(\d+)$"
```

...

```
# TRACK FIX: DISCOGS~TRACK NUMBER / TOTALTRACKS
outputto "title"
sayoutput "tracks"
outputto "track"
sayoutput "discogs pone track / totaltracks temp"
set "discogs pone track / totaltracks temp"
```

The first stands in the middle of my scripts, the second at the end.

I think you you can use it for your beatport script, if you just replace the first nine lines with this:

```
# TRACK COUNTER
gotoline 1
joinuntil "<name>Users Also Bought</name>"
regexpreplace "</track>" "<<<Track>>>I<<<Track>>>"
regexpreplace ".*?(<<<Track>>>.*<<<Track>>>).*" "$1"
regexpreplace "<<<Track>>>[^I].*?<<<Track>>>" "<<<Track>>>"
replace "<<<Track>>>" ""
```

And here is the protocol of these parts from the debug file. It's for a release with 12 tracks.

debug_track_totaltrack.txt (62.3 KB)

Please tell me the exact script-lines you don't understand, if you have further questions. I'm always willing to help if I find the time.

The new core elements are

```
do # get seperated tracknumbers
regexpreplace "^(I)(I+)" "$2|$1$2"
findinline "I"
while "I"
```

this transforms

IIIIIIIIIIII

(was later transformed to 12 = totaltrack)

to

I|II|III|IIII|IIIII|IIIIII|IIIIIII|IIIIIIII|IIIIIIIII|IIIIIIIIII|IIIIIIIIIII|III

IIIIIIIII

(is later transformed to 1|2|3|4|5|6|7|8|9|10|11|12 = all tracknumbers, the last one representing also totaltracks)

So I have now at this point my own track counter and are not longer dependend on the one built into Mp3tag. This also enables me to write exact as many tracknumbers as I need and drop the long list or 99 say ... sayoutput ... seqeuences of my first solution.

the second new element is this:

```
do
say "|"
movechar 1
sayuntil "|"
say "/"
sayregexp "(\d+)$"
while "|" 30
```

it parses the web site at the line 1|2|3|4|5|6|7|8|9|10|11|12

always saying moving to the next number (movechar 1) saying that number (sayuntil "|") and then saying the the last number (sayregexp "(\d+)$")

**EDIT:**

I have now idea why i limited the do ... while loop to 30. Also it seems to have no effect as tracknumbers higher than 30 are also written without problem. I think I just left it there from the process of finding the right code for this loop where i had some proplems with infinite loops which let Mp3tag crash. I will delete this in the next update.

debug_track_totaltrack.txt (62.3 KB)