Video files are sorted by length in wrong order

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
luoruiming
Posts: 1
Joined: 08 Oct 2021 08:36

Video files are sorted by length in wrong order

Post by luoruiming »

Video files are sorted by length in wrong order. For example, when sorted by length, a 2-hour video display is shorter than a 3-minute video display.
To see the attached files, you need to log into the forum.

highend
Posts: 14993
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Video files are sorted by length in wrong order

Post by highend »

XY is not aware of what kind of data is returned by that video length property and doesn't know how to sort it correctly

Use a custom column with a script instead. That should be sortable (at least for videos not larger than 24 hours)

Code: Select all

    $nsecs = property("System.Media.Duration", <cc_item>);

    // To get real seconds from nanoseconds
    $secs = round($nsecs * 0.0000001);

    $hours = $secs / 3600;
    if ($hours >= 1) {
        $hours = format(regexmatches($hours, "^\d+"), "00");
        $secs  = $secs - $hours * 3600;
    } else { $hours = "00"; }

    $mins = $secs / 60;
    if ($mins >= 1) {
        $mins = format(regexmatches($mins, "^\d+"), "00");
        $secs = $secs - $mins * 60;
    } else { $mins = "00"; }

    return $hours . ":" . $mins . ":" . format($secs, "00");
One of my scripts helped you out? Please donate via Paypal

Post Reply