Author Topic: Search Filter based on File Date ...  (Read 2417 times)

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
Search Filter based on File Date ...
« on: January 06, 2018, 10:56:22 PM »
I would like to be able to limit the search scope by file date, e.g.
   * only search in files changed in the last week
   * only search in files older than 1 month

This should also apply to the Find and Replace "Files", e.g.
   * find all "*.pl" files which changed in the last day
   * find all "*.h" files older than 1 year

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Search Filter based on File Date ...
« Reply #1 on: January 07, 2018, 01:46:07 AM »
There was also a request to filter by size.
Much of this you can do in Windows explorer, but there is no way for Slick to search the set of files selected in Explorer.
Searching using a text file list of filenames would be a round-about way to support it, assuming the user has a way to generate the list of files.

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Search Filter based on File Date ...
« Reply #2 on: January 07, 2018, 03:07:17 AM »
One way to do it is to use the file manager as I mentioned here
https://community.slickedit.com/index.php/topic,15938.msg61009.html#msg61009

File menu -> file manager -> new file list  - or use the fileman command.  Enter the folder you want to search in.  Slick will create a buffer with a list of all the files.  Use right click -> "append files" to add more files to the list.  Right click, select sort - select sort by date in the primary sort.  Untick secondary sort then tick it again to allow secondary sort criteria if you want.

Then go to the top of the file, hold down the shift key and press down arrow until all the files you want to search in have a "right arrow"  (greater than sign) at the start.  Then use right click -> global find (or replace).

You can do some of it with macros as below.  The second macro below generates a fileman type listing of the current workspace files.  As a side effect, it generates a list of workspace files into a text file in the configuration folder (because there should be write access to this folder) called flist1.txt. 

I wouldn't be surprised if there's a window/buffer leak in here somewhere - as long as you close slick every now and then it should be fine... :)

Once you have the date sorted fileman listing, you could use the mouse and column selection to get a list of files to search in and pass that to the find in files dialog - via a macro.

Code: [Select]
#include "slick.sh"
     
_command yyy() name_info(',')
{
   _macro('R',1);
   cd('C:\temp1');
   dir("+t -d *.*");
   cd('C:\temp2');
   append_dir("-d *.txt *.h");
   fsort("e a d d");
   top_of_buffer();
}


Code: [Select]
#include "slick.sh"
_command fileman_list_workspace_files_date_sorted() name_info(',')
{
   _macro('R',1);
   _str flist[];

   _getWorkspaceFiles(_workspace_filename, flist);
   if (flist._length() == 0)
      return -1;

   _str tfn = _ConfigPath() :+ 'flist1.txt';

   int new_wid, orig_wid;
   boolean was;
   if (_open_temp_view(_maybe_quote_filename(tfn), new_wid, orig_wid, '', was, true, false, 0, true) != 0)
      return -2;

   if ( p_buf_name != tfn ) {
      _delete_temp_view(new_wid);
      activate_window(orig_wid);
      return -3;
   }

   top();
   int k;
   for ( k = 0; k < flist._length(); ++k ) {
      insert_line(flist[k]);
   }
   _save_file();
   close_buffer();

   typeless status = edit('+futf8 +t');
   if (status) {
      return (status);
   }
   fileman_mode();

   read_list(tfn);
   message('Sorting...');
   fsort("e a d d");
   top_of_buffer();
   docname('List of ' :+ _workspace_filename);
   p_modify = false;
   p_buf_flags = p_buf_flags|VSBUFFLAG_THROW_AWAY_CHANGES;
}
« Last Edit: January 07, 2018, 07:27:06 AM by Graeme »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Search Filter based on File Date ...
« Reply #3 on: January 07, 2018, 03:12:13 AM »
Also I should mention there's an existing command fileman_list_buffers that you can use to get a fileman type list of open buffers which you can then date sort and search.