Page 1 of 1
Color filter based on folder names in a txt file
Posted: 24 Oct 2023 23:13
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!

Re: Color filter based on folder names in a txt file
Posted: 25 Oct 2023 18:10
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^^
Re: Color filter based on folder names in a txt file
Posted: 25 Oct 2023 22:36
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.
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!
Re: Color filter based on folder names in a txt file
Posted: 25 Oct 2023 23:44
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^^
Re: Color filter based on folder names in a txt file
Posted: 26 Oct 2023 15:10
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).
Re: Color filter based on folder names in a txt file
Posted: 26 Oct 2023 16:00
by highend
tagitems() expects full paths, not parts of it.
Re: Color filter based on folder names in a txt file
Posted: 26 Oct 2023 16:55
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.