Author Topic: Additional Functions for more expressive (readable) Templates  (Read 1296 times)


  • Guest
Currently, the Template Editor allows:


but for multiple conditions the template starts becoming unwieldy:


I am wondering if some of the following functions could be supported:


Equalities as functions on strings or numbers:


Alternatively, these equalities and AND, OR, NOT can be implemented as part of the $If statement's condition in addition to "=".

I know that virtual tags can act as functions, but sometimes I want to temporarily define a sub-function that can be reused later within the same template, and only within that template. Say:


I guess, what I am wondering is can templates be made more expressive because my currently auto-reorganization template looks like  this (with indentation removed, added for readability here):

$RxReplace(<Album Artist>,"(^\.|\.$)","-")
$If(<Album Artist>="Various Artists",,
    $If($IsMatch(<Album>,"^.* \((EP|Single)\)$")=T,
      $If($IsMatch(<Album>,"^.* \(EP\)$")=T,\EPs,\Singles),
    $If($Len(<Album Kind>)=0,,\<Album Kind>))))
$RxReplace($If(<Folder Name>=<Album [Year]>,\$RxReplace(<Album [Year]>,"^\.","-"),
  $If($IsMatch(<Folder Name>," [\[\(][0-9]+[\)\]]$")=T,\$RxReplace(<Folder Name>,"^\.","-"),
  $If($IsMatch(<Album>," [\[\(][0-9]+[\)\]]$")=T,\$RxReplace(<Album>,"^\.","-"),
      \$RxReplace(<Album>,"(^\.|\.$)","-"))))," \((Single|EP)\)",)\
<Disc-Track#> <Title>

It's like this because the exceptions currently cannot be chained or cascade nor does the character mapping support the special case of the first and last characters in a path component (i.e.: changing '.' to '_' when as the first or last characters in a directory or filename). My concern is this could become more unwieldy as I add more conditions to it.

P.S.: Code highlighting could be helpful too.
Last Edit: December 27, 2020, 09:49:26 PM by pseudonym