Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Need help with custom track number formatting string (Read 564 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]
$if(%totaldiscs%,$ifgreater(%totaldiscs%,1,$num(%discnumber%,$len(%totaldiscs%))-,),$ifgreater(%discnumber%,1,%discnumber%-,))$if2($num(%tracknumber%,$len(%totaltracks%)),)
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]
$if2($num(%tracknumber%,$len(%totaltracks%)),)$replace($meta(tracknumber),0,,1,,2,,3,,4,,5,,6,,7,,8,,9,,) 
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]
$puts(TRACK,0012a3)

$right($replace($get(TRACK),$num($get(TRACK),),),$sub($strstr($get(TRACK),$num($get(TRACK),)),1))

$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]
$puts(TRACK,0000012-a3)

$substr($replace($get(TRACK),$num($get(TRACK),),),$sub($strstr($get(TRACK),$num($get(TRACK),)),),$len($replace($get(TRACK),$num($get(TRACK),),)))

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.