Examples: Custom grouping with Evaluator (Opus 13)

Here's a quick example of how to set up a custom way to group files.

The aim is to take each filename, remove anything after the first bracket, and use what's left as the group name:

Setting it up:

  1. Go to Preferences / File Display Columns / Evaluator Groups

  2. Click Add Scheme

  3. Give it a name, and paste in this code:

    s = Stem(value);
    pos = InStr(s, " (");
    if (pos <= 0) return s;
    return Left(s,pos);
    

  4. Assign it to the Name column:

Using it:

Right-click the Name column and it'll be one of the grouping options:

1 Like

See Evaluator Functions for documentation on built-in functions Evaluator code can use.

The code editor can also give you a list of functions and variables, with basic information about each:

1 Like

Another example - Split into groups of 10

Evaluator clause:

  •  return ((value+9)/10) as str;
    

Columns:

  • General / Index

Result:

1 Like

So `value' as an index column is an integer data type ?
Division results in an integer data type and does not result in any Modulus remainder or data type conversion ?
For instance, 12 mod 10 = 2 .

It works great !
Thanks !

Group by Year and Month or Year and Week of dates

Evaluator clause:

return DatePart(value, "yyyy-MM");

or

return DatePart(value, "yyyy-WW");

Columns:

  • Modified (date)
  • Modified (date and time)
  • ... (any date field)

Result:

Scheme as XML
<?xml version="1.0"?>
<evalgroupscheme desc="Year and Month" scheme_name="yyyy_MM" sort="yes">
	<eval>return DatePart(value, &quot;yyyy-MM&quot;);</eval>
	<groups enable="no" />
</evalgroupscheme>
4 Likes