How can I set the track numbers on a Vinyl release for A- and B-side separately?

I try to tag this Vinyl album with MusicBrainz Picard v2.13.3:

For the Vinyl track number itself I found this very useful documentation and:
$set(tracknumber,%_musicbrainz_tracknumber%)

But how can I set the total number of tracks to 8 for the A-side and 6 for the B-side instead of 14 for the total number of tracks (totaltracks) for both sides?

The result I’m looking for for the track number is

A1/8
A2/8
...
A8/8

and

B1/6
B2/6
...
B6/6

I’m pretty sure you can do this using the “Persistent Variables” plugin (documentation). To do this, I think you need to have 2 separate tagging scripts – one to collect the track-per-side count, and the other to apply the value.

The following (untested) scripts should do what you want:

Script 1 - Collect the information

$if($in($left(%_musicbrainz_tracknumber%,1),0123456789),
  $noop(Normal numeric track number beginning with a digit)
  $noop(Do nothing)
,
  $noop(Vinyl track number beginning with a letter)
  $noop(Increment the track count for this disc number and side)
  $set(_counter,$upper($left(%_musicbrainz_tracknumber%,1))%discnumber%)
  $set_a(%_counter%,$add($if2($get_a(%_counter%),0),1))
)

Script 2 - Apply the information

$if($in($left(%_musicbrainz_tracknumber%,1),0123456789),
  $noop(Normal numeric track number beginning with a digit)
  $noop(Do nothing)
,
  $noop(Vinyl track number beginning with a letter)
  $noop(Save the total track count for this disc number and side)
  $set(_counter,$upper($left(%_musicbrainz_tracknumber%,1))%discnumber%)
  $set(totaltracks,$get_a(%_counter%))
)

This should set the %totaltracks% tag to the total number of tracks on that side of that vinyl disc number of the album. If the %_musicbrainz_tracknumber% tags are not in the vinyl track numbering format (beginning with a letter), then the special processing should be ignored.

1 Like

Thank you very much @rdswift - I just need some time to understand and test it.

Sorry, I just re-read your original message and I think I misunderstood what you wanted. Try the following instead for the second script:

Script 2 - Apply the information

$if($in($left(%_musicbrainz_tracknumber%,1),0123456789),
  $noop(Normal numeric track number beginning with a digit)
  $noop(Do nothing)
,
  $noop(Vinyl track number beginning with a letter)
  $noop(Save the total track count for this disc number and side)
  $set(_counter,$upper($left(%_musicbrainz_tracknumber%,1))%discnumber%)
  $set(tracknumber,%_musicbrainz_tracknumber%/$get_a(%_counter%))
)
1 Like

FANTASTIC!
Your second script does exactly what I wanted it to do!
Thanks again, I would never have found this solution without your help and support.

2 Likes

One little thing that I don’t understand yet:
Why do I see a difference between Original Value for the track A1/8 and the New Value A1/9

That’s because of an “oops” in my scripts. I forgot that matching a file to a track will cause the scripts to be re-run.

In any event, these slightly revised scripts should take care of that:

Script 1 - Collect the information

$if($in($left(%_musicbrainz_tracknumber%,1),0123456789),
  $noop(Normal numeric track number beginning with a digit)
  $noop(Do nothing)
,
  $noop(Vinyl track number beginning with a letter)
  $noop(Increment the track count for this disc number and side)
  $set(_counter,$upper($left(%_musicbrainz_tracknumber%,1))%discnumber%)
  $if($get_a(%_counter%%tracknumber%),,
    $noop(Only increment in not already processed)
    $set_a(%_counter%,$add($if2($get_a(%_counter%),0),1))
    $set_a(%_counter%%tracknumber%,1)
  )
)

Script 2 - Apply the information

$if($in($left(%_musicbrainz_tracknumber%,1),0123456789),
  $noop(Normal numeric track number beginning with a digit)
  $noop(Do nothing)
,
  $noop(Vinyl track number beginning with a letter)
  $noop(Save the total track count for this disc number and side)
  $set(_counter,$upper($left(%_musicbrainz_tracknumber%,1))%discnumber%)
  $set(tracknumber,%_musicbrainz_tracknumber%/$get_a(%_counter%))
)

Sorry about so many iterations to get this working correctly.

2 Likes