Author Topic: Select All Files matching the Date of File In Focus  (Read 17019 times)

AlanJB

  • VIP Member
  • *****
  • Posts: 436
  • VERY old Programmer
    • View Profile
Select All Files matching the Date of File In Focus
« on: April 20, 2016, 10:41:22 »
I have been using MC for about 2 weeks now & got my head around the configuration and even written a couple of custom commands.
Now I am stumped after a couple of days of scripting failure.  I feel sure that what I want should be achievable with MultiScript, but I cannot get it to work.

I simply want to select all the files in the panel with a Last Modified Date that matches that of the file in focus.

Has anyone accomplished this or can give me some pointers?

TIA

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4449
    • View Profile
    • Multi Commander
Re: Select All Files matching the Date of File In Focus
« Reply #1 on: April 20, 2016, 11:23:30 »
First I think you need to have a to and from date, you can not just do Date of File1 is equal to Date of File2, because filetime has a resolution of 1sec. (really 100ms but only 1s in script)

The MultiScript function  GetFileTime(..) return time on seconds from 1970-01-01 00:00:00

If you want to match entire DATE..  like entire day.. then you need to calculate the start/end of the day and then use that as reference.

Use  GetSourceItems(..)/GetTargetItems to get all items in a list
and GetTargetFocusPath (or Source) as the reference item

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4449
    • View Profile
    • Multi Commander
Re: Select All Files matching the Date of File In Focus
« Reply #2 on: April 20, 2016, 12:23:16 »
If you need to figure out the start of a day based on a filedate, You need to do some math
Or you can make the program do it for you

Code: [Select]
@var $filedate = GetFileTime( $PathToFile );
// Get date as string
@var $date = FormatDate( "yyyy-MM-dd" , $filedate );
// parse date to num value.
@var $startOfDay = ParseDateTime($date, "%Y-%m-%d");

AlanJB

  • VIP Member
  • *****
  • Posts: 436
  • VERY old Programmer
    • View Profile
Re: Select All Files matching the Date of File In Focus
« Reply #3 on: April 20, 2016, 16:19:38 »
Thanks Mathias.

FormatDate() was what I was missing.