Page 1 of 1

Sync Select to find OLDER created dates

Posted: 26 Jul 2023 16:33
by DVD
Is there a way to select file matches with an 'older' created date using Sync Select ...or another method?

I need to be able to detect any files on either pane that have matching names and last modified dates, but have different (older) created dates.

Any help will be much appreciated!!

Re: Sync Select to find OLDER created dates

Posted: 26 Jul 2023 17:20
by highend
A script should be able to do such stuff...

Code: Select all

end (!get("#800")), "No dual-pane mode active, aborted!";

    $aItems = quicksearch("/nf", <curpath>, , "m");
    $iItems = quicksearch("/nf", get("path", "i"), , "m");
    end (!$aItems || !$iItems), "No file(s) in active or inactive pane, aborted!";

    $aSel = "";
    $iSel = "";
    foreach($aItem, $aItems, <crlf>, "e") {
        $item  = gettoken($aItem, 1, "|");
        $file  = gpc($item, "file");
        $esc   = regexreplace($file, "([\\^$.+()\[{])", "\$1");
        $match = regexmatches($iItems, "^.+\" . $esc . "\|.+?(?=\r?\n|$)");
        if (!$match) { continue; }

        $aMDate = gettoken($aItem, 3, "|");
        $iMDate = gettoken($match, 3, "|");
        if ($aMDate != $iMDate) { continue; }

        $aCDate = gettoken($aItem, 4, "|");
        $iCDate = gettoken($match, 4, "|");
        if (datediff($iCDate, $aCDate, "s") <= 0) { continue; }

        $aSel .= $item . <crlf>;
        $iSel .= gettoken($match, 1, "|") . <crlf>;
    }
    end (!$aSel || !$iSel), "No match(es) found, aborted!";

    selectitems $aSel, 4:="a";
    selectitems $iSel, 4:="i";
    status gettoken($aSel, "count", <crlf>) - 1 . " match(es) found...";

Re: Sync Select to find OLDER created dates

Posted: 27 Jul 2023 08:22
by DVD
That's great - thanks so much for the effort!

I have tested, but the script just says "no match(es) found, aborted"

Re: Sync Select to find OLDER created dates

Posted: 27 Jul 2023 08:36
by highend
and the files in the INACTIVE pane have the same name, same modified date and an OLDER created date?

Look at the image. The three selected files have the same name, same modified date but on the inactive pane a created date that's one minute older than the ones in the active pane...
XY_script.png

Re: Sync Select to find OLDER created dates

Posted: 27 Jul 2023 18:13
by DVD
I figured out what I was doing - it only works when the left pane is activated, not the right pane - no problem, but could it do both?

Also, please can you only highlight the oldest files on whichever side - so in your example, just the 3 files in the right pane would be highlighted.

Finally, to push my luck, is it possible to have an alternative version which ignores the modified date status - but still focuses on the oldest created date.

My sincere thanks for your efforts!!!

Re: Sync Select to find OLDER created dates

Posted: 27 Jul 2023 23:09
by highend
01. It does already work with both panes
02. Comment out the selectitems statement for the active pane?
03. Comment out the if () comparison for the ...MDate variables?

Re: Sync Select to find OLDER created dates

Posted: 28 Jul 2023 01:50
by DVD
Yep, it does work on both panes - I think there's something funky going on with my XYplorer - sorted now though.

Sorry to be a pain, but I tried the commenting out suggestion, but it doesn't identify which side is the oldest Created Date of the files in both panes.

Below is a mock up of what I'm trying to achieve. The goal is for whichever side I run the script, it highlights any file that has a matching name on the other pane (with/without same Modified Date) and highlights the file on each side which has the oldest Created Date...

...and ideally it would include folders too :tup:
Screenshot 2023-07-28 003954.jpg

Re: Sync Select to find OLDER created dates

Posted: 28 Jul 2023 19:07
by highend

Code: Select all

end (!get("#800")), "No dual-pane mode active, aborted!";

    $activePaneItems   = quicksearch("/n", <curpath>, , "m");
    $inactivePaneItems = quicksearch("/n", get("path", "i"), , "m");
    end (!$activePaneItems || !$inactivePaneItems), "No file(s) in active or inactive pane, aborted!";

    $activePaneSelection   = "";
    $inactivePaneSelection = "";
    foreach($activePaneItem, $activePaneItems, <crlf>, "e") {
        $item  = gettoken($activePaneItem, 1, "|");
        $file  = gpc($item, "file");
        $esc   = regexreplace($file, "([\\^$.+()\[{])", "\$1");
        $match = regexmatches($inactivePaneItems, "^.+\" . $esc . "\|.+?(?=\r?\n|$)");
        if (!$match) { continue; }

        // $activePaneModifiedDate   = gettoken($activePaneItem, 3, "|");
        // $inactivePaneModifiedDate = gettoken($match, 3, "|");
        // if ($activePaneModifiedDate != $inactivePaneModifiedDate) { continue; }

        $activePaneCreatedDate   = gettoken($activePaneItem, 4, "|");
        $inactivePaneCreatedDate = gettoken($match, 4, "|");
        $difference              = datediff($inactivePaneCreatedDate, $activePaneCreatedDate, "s");
        // Younger
        if ($difference < 0) {
            $activePaneSelection .= $item . <crlf>;
        // Older
        } elseif ($difference > 0) {
            $inactivePaneSelection .= gettoken($match, 1, "|") . <crlf>;
        // Same date, select both
        } else {
            $activePaneSelection   .= $item . <crlf>;
            $inactivePaneSelection .= gettoken($match, 1, "|") . <crlf>;
        }

    }
    end (!$activePaneSelection && !$inactivePaneSelection), "No match(es) found, aborted!";

    selectitems $activePaneSelection,   4:="a";
    selectitems $inactivePaneSelection, 4:="i";
    status "Match(es) found...";

Re: Sync Select to find OLDER created dates

Posted: 28 Jul 2023 22:48
by DVD
Superb - works like a charm - thanks v much!!!

...I've added something into your PayPal tip jar :beer:

Re: Sync Select to find OLDER created dates

Posted: 28 Jul 2023 22:52
by highend
Seen that, thanks :tup: