Skip to main content


Please be aware that much of the software linked to or mentioned on this forum is niche and therefore infrequently downloaded. Lots of anti-virus scanners and so-called malware detectors like to flag infrequently downloaded software as bad until it is either downloaded enough times, or its developer actually bothers with getting each individual release allow listed by every single AV vendor. You can do many people a great favor when encountering such a "problem" example by submitting them to your AV vendor for examination. For almost everything on this forum, it is a false positive.
Topic: Need help with custom track number formatting string (Read 259 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Need help with custom track number formatting string

I have a custom track number column formatting string that goes like this
Code: [Select]
and produces track numbers with disc numbers included if present, removes in-tag zero padding and optionally adds its own padding according to the total ammount of both. It also ignorines discnumber if totaldiscs isn't higher than 1. Like this: 3-07

Sometimes I find albums that, for a number of reasons need to have non-numeric characters in the track or disc number field, which are usually lowercase alphabetic characters, like this. "1a" "1b" "1c"
I don't recall having seen this yet, but I figure that at some point I might also find someone having added dashes (-) and periods (.) as separators for some purpose.

So, what I would like to do is to keep all the functionality of my tracknumber formatting string, with all the padding and so on), but modify something so that I get to somehow add these sub-track strings if present.

I'm guessing I would need something that could take the tracknumber field's raw contents ( $meta() ) and then another function that strips the initial numerical part that %tracknumber% returns, and add it to the end of the string.

Furthermore, since this would make those tracks with extra characters become misaligned with the rest that don't have them... would there be any way to fix that, other than adding another custom column just for those sub-track strings?

Re: Need help with custom track number formatting string

Reply #1
If I understand what you want correctly, something like this should do the trick
Code: [Select]
$ifgreater(%totaltracks%,9,$ifgreater($len($meta(tracknumber)),1,$meta(tracknumber),0%track number%),$replace($meta(tracknumber),0,,)) 

As for the padding, if the album has both tracks with and without non-numerical characters, I don't believe it's possible. That would require checking if metadata of other files has certain values, and I don't think there are instruments for that. I may be wrong tho.
I guess you can add universal padding with spaces for anything shorter than 3 characters, or something like that.

Re: Need help with custom track number formatting string

Reply #2
Or the way you wanted to do it:
Code: [Select]
however, if the format of thracknumber field is weird, like "01.a1", it will be messed up.

Re: Need help with custom track number formatting string

Reply #3
@Pollux88 Thanks for the suggestions. You've given me some ideas. I'm trying something new but I don't have it down yet.
I'll post again when I get it or give up.

Re: Need help with custom track number formatting string

Reply #4
I'm getting somewhere with the separation of the substring.
Code: [Select]


$right($replace(%track number%,$num(%track number%,),),$sub($strstr(%track number%,$num(%track number%,)),1))

Good for a number of cases, but breaking for weirder fields like some I just found ("x9-08"), which I'll probably just try to reformat manually when I find them... or I could try to make something even more convoluted to try to automate.

UPDATE: Nevermind, it's breaking for some reason...

UPDATE2: Working now
Code: [Select]


In the end, trying to cover all possible crazy schemes out there seems more of a task for a learning IA than for even an experienced coder, which I'm a million miles from being anyway.

Code: [Select]
$pad($substr($replace(%track number%,$num(%track number%,),),$sub($strstr(%track number%,$num(%track number%,)),),$len($replace(%track number%,$num(%track number%,),))),3)
With 3char padding, ready to add at the end of the normal tracknumber string.

SimplePortal 1.0.0 RC1 © 2008-2021