Evaluator Groups: Grouping by date, similar to the default scheme

When grouping files by the default scheme, using a file's modification/creation date, this gives the following output:

image

Using an evaluator group, you can do similar things and some more.
In this example, there are files which contain the word "ERROR" in their filename. Those specific files should get their own group, still respecting the modification/creation date grouping scheme.

To get this task solved, you have got to use static evaluator groups.

The definition is as below.

Additionally, set up some columns to which this new scheme is restricted to.

For convenience, you can copy and paste the code below.
The main part is about comparing the current date with the built-in variable value . This variable contains the date, either the modification or creation date of a single file during it's processing.

Hence, we have restricted the new grouping scheme to the four columns above. This ensures that no other value hits the code during execution.

The comparison result defines the group value (1,3,5,7), see static values in screenshot above.

You may notice below, that if a file contains the word ERROR, the result is always incremented by 1. In this case, the initial result value becomes: 2,4,6,8 (that is a group name with addition (with error).

If none of the comparisons is hit, the return value is always 9. This is the group name A long time ago. There is no error processing for appropriate filenames in this case.

if (is_dir) { return };

result = 9;

if ( DateDiff("d", Now(), value) == 0 ) { result = 1; }
 elseif( DateDiff("ww", Now(), value) == -1 ) { result = 3 }
  elseif( DateDiff("m", Now(), value) == -1 ) { result = 5 }
   elseif( DateDiff("yyyy", Now(), value) == -1 ) { result = 7 };

if (RegExS( name, "(.*)_ERROR(.*)" ) and result < 9) {
	result += 1;
};

return(result);

To use this new scheme, you have to use e.g. folder format and configure the grouping appropriate.

The final result looks like:

Hope, this example is useful for anybody else or at least for some self teaching purposes.

3 Likes

can format the columns when using evaluator groups to achieve something like so:
image

here is example code

days = DateDiff("d", modified, Now());
groupName = "";
groupDayNumber = DatePart(modified, "MMM") + " " + DatePart(modified, "d") + (Right(DatePart(modified, "d"),1) == "1" ? "st" : Right(DatePart(modified, "d"),1) == "2" ? "nd" : Right(DatePart(modified, "d"),1) == "3" ? "rd" : "th");
groupDayName = " " + DatePart(modified, "dddd") + " ";

orderOut = 0;

if
(days < 1)
{
  groupName = "Today";
  orderOut = 1000;
}
elseif
(days < 2)
{
  groupName = "Yesterday";
  orderOut = 900;
}
elseif
(days < 3)
{
  groupName = "2 days ago";
  orderOut = 800;
}
elseif
(days < 4)
{
  groupName = "3 days ago";
  orderOut = 700;
}
elseif
(days < 5)
{
  groupName = "4 days ago";
  orderOut = 600;
}
elseif
(days < 6)
{
  groupName = "5 days ago";
  orderOut = 500;
}
elseif
(days < 7)
{
  groupName = "6 days ago";
  orderOut = 400;
}
elseif
(days < 8)
{
  groupName = "7 days ago";
  orderOut = 300;
}
else
{
  groupName = "More than a week ago";
  groupDayName = "";
  groupDayNumber = "";
  orderOut = 100;
}

groupName = groupName as "%-20" + groupDayNumber as "%-30" + groupDayName as "%-43";

return [name = groupName; order = orderOut;];