Feature Request: Numeric functions $min and $max in Picard's scripting language

Please consider adding script functions $min and $max to return the minimum and maximum of a set of numeric values, such as years, as covered in this previous post.

First off, the current $lt and $gt functions do not work with dates. They only work with integers. That said, it should be fairly easy to create new functions to work with text arguments such as dates. Adding $min and $max functions, and their text argument equivalents, should also be fairly easy.

My understanding is that no new functionality is being added to Picard until after v2.8 is released (which should be soon – later this month?).

Please enter a ticket in the PICARD section of the ticket tracker, so I have something to refer to when I start work on it. Until it is included in Picard, I could probably develop a plugin to add the new functions if there is enough interest.

2 Likes

Until such time as the functions have been added to Picard, I have put together a plugin that adds some text-based scripting functions. The pre-release (testing) version of the plugin is available from my plugin repository on GitHub.

Any testing comments would be appreciated so the plugin can be fine-tuned for official release (or the functionality added to Picard).


Text Compare Functions [Download]

Overview

This plugin provides text-based comparison scripting functions similar to the integer-based comparison functions $lt(), $lte(), $gt() and $gte(), plus two additional functions to find the minimum and maximum values using a text-based comparison. These can be used for comparing non-integer values such as dates.

Scripting Functions Added

This plugin adds six new scripting functions to allow text-based operations:

$tlt(x,y)

Returns true if x is less than y using a text comparison.

$tlte(x,y)

Returns true if x is less than or equal to y using a text comparison.

$tgt(x,y)

Returns true if x is greater than y using a text comparison.

$tgte(x,y)

Returns true if x is greater than or equal to y using a text comparison.

$tmin(x,…)

Returns the minimum value using a text comparison. Can be used with an arbitrary number of arguments.

$tmax(x,…)

Returns the maximum value using a text comparison. Can be used with an arbitrary number of arguments.

Examples

Example 1:

Determine if the release is a re-issue based on the release date, so that it can be used in the file naming script.

$set(_type,$if($and(%date%,%originaldate%),$if($tgt(%date%,%originaldate%),Original Release,Re-Release),Unknown))

Example 2:

Find the earliest of recording date or release date.

$set(_type,$if($or(%date%,%originaldate%),$tmin($if2(%date%,9999-12-31),$if2(%date%,9999-12-31)),0000-00-00))
5 Likes

Thank you, I will try that