Color filter based on folder names in a txt file

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Tanta0104
Posts: 4
Joined: 19 Oct 2023 13:36

Color filter based on folder names in a txt file

Post by Tanta0104 »

Hi there I was wondering if there is a way to apply an instant color filter or a regular one to color folders that their name exists in a text file.
I appreciate your help as I am new.
Thanks! :ninja:

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

Re: Color filter based on folder names in a txt file

Post by highend »

Code: Select all

$file    = "D:\Users\Highend\Downloads\Folders.txt";
    $content = readfile($file, , , 65001);
    $items   = "";
    foreach($item, $content, <crlf>, "e") {
        if ($item == "") { continue; }
        $items .= " OR dir:" . quote($item);
    }
    if ($items) {
        $items = regexreplace($items, "^ OR ");
        colorfilter($items . ">BF6000,");
    }
But be aware that the list of folders can't contain full paths, only names of folders...

Otherwise you would need to use labels^^
One of my scripts helped you out? Please donate via Paypal

Tanta0104
Posts: 4
Joined: 19 Oct 2023 13:36

Re: Color filter based on folder names in a txt file

Post by Tanta0104 »

I appreciate it. It is what i needed.
I was about to ask you how to remove the color filter but it was easy to figure out that you need to press the button again. :lol:
In terms of the other way you suggested (labels) I was under the impression that labels can only be applied manually. Is there a way to apply them using a similar script that reads again from a txt file?

Thanks!

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

Re: Color filter based on folder names in a txt file

Post by highend »

Code: Select all

$file    = "D:\Users\Highend\Downloads\Folders.txt";
    $content = readfile($file, , , 65001);
    $items   = "";
    foreach($item, $content, <crlf>, "e") {
        if ($item == "") { continue; }
        $items .= $item . <crlf>;
    }
    if ($items) {
        tagitems("label", "Orange", $items);
    }
Now find a way to reset the labels^^
One of my scripts helped you out? Please donate via Paypal

Tanta0104
Posts: 4
Joined: 19 Oct 2023 13:36

Re: Color filter based on folder names in a txt file

Post by Tanta0104 »

I am trying to find out first why the labels script doesn't work. I am using the exact same txt file with the previous script (color filter).

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

Re: Color filter based on folder names in a txt file

Post by highend »

tagitems() expects full paths, not parts of it.
One of my scripts helped you out? Please donate via Paypal

Tanta0104
Posts: 4
Joined: 19 Oct 2023 13:36

Re: Color filter based on folder names in a txt file

Post by Tanta0104 »

Ok I see, now what you wrote at the bottom of your fist post makes sense (about full paths and labels).
To reset them, it can be done with a second button using this command:

tagitems("label", "", $items);

but I prefer the single toggle button as the color filter one that does both.
I appreciate your help.

Post Reply