Page 1 of 1

Group by "Type"

Posted: 03 Jan 2023 18:24
by steverance
Some of our users have expressed the ability to be able to use the "group by" feature available in Windows Explorer.
I cant seem to locate a native way of doing this in XY ... is this possible?

For example ...
Screenshot 2023-01-03 091642.png

Re: Group by "Type"

Posted: 03 Jan 2023 19:47
by admin
Nope.

Re: Group by "Type"

Posted: 03 Jan 2023 21:35
by GreetingsFromPoland
admin wrote: 03 Jan 2023 19:47Nope.
why ? is it too difficult to add or a limitation of VB ?

DO has it and it is quite useful :
Image-002.png

Re: Group by "Type"

Posted: 04 Jan 2023 01:39
by RalphM
Well, one can sort the list by extension if the column is shown.
The only thing missing are the group titles.

Re: Group by "Type"

Posted: 04 Jan 2023 11:57
by Horst
Sorting by extension doesn't help much.
I classify .rtf, .pdf and .doc as documents for example and the sort can't sort them together.
In Total Commander I used a plugin which allows to define arbitrary file groups and their postion in the list.
But I stopped using this feature as in large lists the sorting order looks confusing.

Re: Group by "Type"

Posted: 04 Jan 2023 13:36
by highend
Via a scripted custom column (define groups or use XYplorer's inbuilt ones and if an extension matches a group, return that group)...

Ofc no headers^^

Re: Group by "Type"

Posted: 04 Jan 2023 16:03
by highend
Required:
Configuration - General - Refresh, Icons, History - Scripting - [x] Remember permanent variables

E.g. this script would need to be run first (and atm only once):

Code: Select all

    perm $P_GFT_ARCHIVE = "<ARCHIVE><crlf>" . recase(formatlist(regexreplace(get("genericfiletype", "{:Archive}",    <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_AUDIO   = "<AUDIO><crlf>"   . recase(formatlist(regexreplace(get("genericfiletype", "{:Audio}",      <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_EXE     = "<EXE><crlf>"     . recase(formatlist(regexreplace(get("genericfiletype", "{:Executable}", <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_FONT    = "<FONT><crlf>"    . recase(formatlist(regexreplace(get("genericfiletype", "{:Font}",       <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_IMAGE   = "<IMAGE><crlf>"   . recase(formatlist(regexreplace(get("genericfiletype", "{:Image}",      <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_OFFICE  = "<OFFICE><crlf>"  . recase(formatlist(regexreplace(get("genericfiletype", "{:Office}",     <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_PHOTO   = "<PHOTO><crlf>"   . recase(formatlist(regexreplace(get("genericfiletype", "{:Photo}",      <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_TEXT    = "<TEXT><crlf>"    . recase(formatlist(regexreplace(get("genericfiletype", "{:Text}",       <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_VECTOR  = "<VECTOR><crlf>"  . recase(formatlist(regexreplace(get("genericfiletype", "{:Vector}",     <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_VIDEO   = "<VIDEO><crlf>"   . recase(formatlist(regexreplace(get("genericfiletype", "{:Video}",      <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_WEB     = "<WEB><crlf>"     . recase(formatlist(regexreplace(get("genericfiletype", "{:Web}",        <crlf>), "^\*\."), "s", <crlf>), "l");
    perm $P_GFT_MEDIA   = "<MEDIA><crlf>"   . recase(formatlist(regexreplace(get("genericfiletype", "{:Media}",      <crlf>), "^\*\."), "s", <crlf>), "l");
    writepv;
And the custom column script would then be:

Code: Select all

    // The permanent variables must have already been defined (different script!)
    if (<cc_ext> == "") { return "<NONE>"; }

    $gfts = "$P_GFT_ARCHIVE|$P_GFT_AUDIO|$P_GFT_EXE|$P_GFT_FONT|$P_GFT_IMAGE|$P_GFT_OFFICE|$P_GFT_PHOTO|$P_GFT_TEXT|$P_GFT_VECTOR|$P_GFT_VIDEO|$P_GFT_VIDEO|$P_GFT_MEDIA";

    foreach($gft, $gfts, "|") {
        $esc = regexreplace(<cc_ext>, "([\\^$.+()\[{])", "\$1");
        if (regexmatches($gft, $esc)) {
            return gettoken($gft, 1, <crlf>);
        }
    }
    return "<UNKNOWN>";