Select Items Modified Today.

Discuss and share scripts and script files...
Post Reply
SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Select Items Modified Today.

Post by SkyFrontier »

Looking for a way to easily select folders/files/all modified today?
Here's your fellow script friend which will do this for you...

Code: Select all

   input $b, "Which type of item you want (f=file; d=directory, blank=all)?", "f";
   sortby "Modified", "d";
   setting SortFoldersApart, 1;
   selpos 1;
   $a = formatdate(report ("{modified}",1), "yyyy/mm/dd");
   selfilter $a, $b, modified;
   status "Selection done. Have a nice day!";
//   makecoffee;
...it'll even make you a sweet cup of coffee if you remove the "//" comment! :D
Important notice: according to your regional settings, you may need to edit the "$a = formatdate" values. Mine is dd/mm/yyyy, for instance. If you want to get the latest CREATED files, then set "(report ("{created}",1)" instead, along with the "selfilter $a, $b, created;" field.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Select Items Modified Today.

Post by Stefan »

Here is an different approach, and some other examples too:

EDIT to reflect the script syntax chances from sel +1; to sel "+ 1";

Code: Select all

v9.70.0017 - 2010-11-15 15:18
     ! Scripting: Unary operators + and - were not always parsed
      correctly. Fixed. Now stuff like this works:
        ::echo 1 + --1; //2
        ::echo --(1 * ----2); //2
See a few posts below at http://www.xyplorer.com/xyfc/viewtopic. ... 353#p55353

Code: Select all

"Select modified today"
  sel 1;
  $array="";
  While (1)
  {
     $cur_mdate = report(" {modified}",1);
     if ($cur_mdate==''){selectitems  $array,,,a; break;}
     $DiffResult = datediff($cur_mdate); 
     IF ($DiffResult < 1) {$array = $array . "<curname>|";}
    sel "+1";
  }

Code: Select all

"Select modified last hour"
  sel 1;
  $array="";
  While (1)
  {
     $cur_mdate = report(" {modified}",1);
     if ($cur_mdate==''){selectitems  $array,,,a; break;}
     $DiffResult = datediff($cur_mdate, , "n"); 
     IF ($DiffResult < 61) {$array = $array . "<curname>|";}
    sel "+1";
  }

Code: Select all

"Select biggest file"
  sel 1; sel; #1033;  selectitems "<focitem>";  //Select first file
  $array="";
  $biggest_size = 0;
  While (1)
  {
     $cur_size = report("{size RAW}",1);
     if ($cur_size==""){selectitems  $array; #1048; break;}
     IF ($cur_size > $biggest_size)
     {
        $biggest_size = $cur_size;
        $array = "<curname>";
     }
    sel "+1";
  }

Code: Select all

"Select youngest file"
  sel 1; sel; #1033;  selectitems "<focitem>";  //Select first file
  $array="";  $youngest_date = 0;
  While (1)
  {
     $cur_mdate = "<datem>";
     if ($cur_mdate==""){selectitems  $array; #1048; break;}
     $DiffResult = datediff($cur_mdate,,"h"); 
     IF ( $DiffResult > $youngest_date)
     {}else{
        $youngest_date = $DiffResult;
        $array = "<curname>";
     }
    sel "+1";
  }
Last edited by Stefan on 10 Dec 2010 17:05, edited 1 time in total.

jjk
Posts: 202
Joined: 10 Oct 2007 20:11
Location: Paris

Re: Select Items Modified Today.

Post by jjk »

Hi Stefan

I don't know since when the behaviour of sel has changed, but instead of

Code: Select all

sel +1
you have to write

Code: Select all

sel + 1
(with a space before 1) or

Code: Select all

sel "+1"
else loop is infinite.

Thanks for your coding.

admin
Site Admin
Posts: 65341
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Select Items Modified Today.

Post by admin »

jjk wrote:Hi Stefan

I don't know since when the behaviour of sel has changed...
Since v9.70.0017. You should used "+1" now.

Post Reply