Live filter from item dates

Discuss and share scripts and script files...
Post Reply
highend
Posts: 14427
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Live filter from item dates

Post by highend »

Create a live filter from visible item dates...

For created, modified and accessed
Either as an inputlist or a menu.
If you generally have a lot of visible items I'd choose the inputlist, otherwise the menu can be too long to be really usable...

Code: Select all

    $useWindow = true; // true or false. If false: Use a menu instead

    // Remove date (only!) filter if already present
    if (regexmatches(get("livefilter"), "^dateC: [0-9-]{10}$")) { filter "", 8; end true; }

    // Abort immediately
    end (!<allitems>), "No visible item(s), aborted!";

    $report   = report("{created yyyy-mm-dd}|{modified yyyy-mm-dd}|{accessed yyyy-mm-dd}<crlf>");
    $dateType = popupmenu("Created|Modified|Accessed");
    if ($dateType) {
        $result = GetDate($report, $dateType);
        if ($useWindow) { $select = inputselect("Choose date", $result, <crlf>, 32+8192+16384, , 250, 400); }
        else            { $select = popupmenu($result, 6:=<crlf>); }
        if ($select) {
            if     ($dateType LikeI "Created")  { filter "dateC: $select", 8; }
            elseif ($dateType LikeI "Modified") { filter "dateM: $select", 8; }
            elseif ($dateType LikeI "Accessed") { filter "dateA: $select", 8; }
        }
    }


function GetDate($report, $type) {
    $pattern = "^([0-9-]+?)\|([0-9-]+?)\|([0-9-]+?)$";
    if     ($type LikeI "Created")  { $result = regexreplace($report, $pattern, "$1"); }
    elseif ($type LikeI "Modified") { $result = regexreplace($report, $pattern, "$2"); }
    elseif ($type LikeI "Accessed") { $result = regexreplace($report, $pattern, "$3"); }

    return formatlist($result, "red", <crlf>);
}
One of my scripts helped you out? Please donate via Paypal

eil
Posts: 1804
Joined: 13 Jan 2011 19:44

Re: Live filter from item dates

Post by eil »

I dared to make it into button snippet.
+ Uses Global Live Filter active icon(red one) with yellow background.
+ Has pushed effect when filter activated.
+ Right-click toggles filter. [useful to have tweak CTBNoRClickDefaultCommands= activated, to have only script action/no context menu]

Code: Select all

Snip: CTB 1
  XYplorer 26.80.0410, 22.02.2025 15:17:30
Action
  NewUserButton
Name
  Filter by Date
Icon
  :gvfon*#FFE579
ScriptL
  $useWindow = true; // true or false. If false: Use a menu instead
  
      // Remove date (only!) filter if already present
      if (regexmatches(get("livefilter"), "^dateC: [0-9-]{10}$")) { filter "", 8; end true; }
  
      // Abort immediately
      end (!<allitems>), "No visible item(s), aborted!";
  
      $report   = report("{created yyyy-mm-dd}|{modified yyyy-mm-dd}|{accessed yyyy-mm-dd}<crlf>");
      $dateType = popupmenu("Created|Modified|Accessed");
      if ($dateType) {
          $result = GetDate($report, $dateType);
          if ($useWindow) { $select = inputselect("Choose date", $result, <crlf>, 32+8192+16384, , 250, 400); }
          else            { $select = popupmenu($result, 6:=<crlf>); }
          if ($select) {
              if     ($dateType LikeI "Created")  { filter "dateC: $select", 8; ctbstate(1);}
              elseif ($dateType LikeI "Modified") { filter "dateM: $select", 8; ctbstate(1);}
              elseif ($dateType LikeI "Accessed") { filter "dateA: $select", 8; ctbstate(1);}
          }
      }
  
  
  function GetDate($report, $type) {
      $pattern = "^([0-9-]+?)\|([0-9-]+?)\|([0-9-]+?)$";
      if     ($type LikeI "Created")  { $result = regexreplace($report, $pattern, "$1"); }
      elseif ($type LikeI "Modified") { $result = regexreplace($report, $pattern, "$2"); }
      elseif ($type LikeI "Accessed") { $result = regexreplace($report, $pattern, "$3"); }
  
      return formatlist($result, "red", <crlf>);
  }
  
ScriptR
  #389; ctbstate(0);
ScriptM
  
FireClick
  0
Win 7 SP1 x64 100% 1366x768|1900x1080

kotlmg
Posts: 321
Joined: 30 Jun 2010 17:14

Re: Live filter from item dates

Post by kotlmg »

these scripts are very useful.
Is it possible to
1) add the no of days as argument from topmost date, no of days from bottom most dates.
2) show only files
3)show only folders
4) show both files and folders

thanks.

eil
Posts: 1804
Joined: 13 Jan 2011 19:44

Re: Live filter from item dates

Post by eil »

kotlmg wrote: 01 Mar 2025 03:23 2) show only files
3)show only folders
4) show both files and folders
Type Stats and Filters toolbar button allows that > first filter by date via this script, next select to show only folders, or even only specific type of files.
Win 7 SP1 x64 100% 1366x768|1900x1080

kotlmg
Posts: 321
Joined: 30 Jun 2010 17:14

Re: Live filter from item dates

Post by kotlmg »

thank you.

Post Reply