Toggle File Colors ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
CookieMonster

Toggle File Colors ?

Post by CookieMonster »

How can I toggle files between two different colors ? As well how do you colorize shared network folders for a networked computer ?

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

Re: Toggle File Colors ?

Post by highend »

How can I toggle files between two different colors ?
Which colors, labels / color (or instant color) filters?
As well how do you colorize shared network folders for a networked computer ?
E.g. for a color filter:

Code: Select all

dir:\\<your netbios server name>\folder\*somefolder
Note the "*" in this definition! Without it "*" would be added automatically and then
all subfolders beyond somefolder would be colored as well^^
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Toggle File Colors ?

Post by CookieMonster »

Which colors, labels / color (or instant color) filters?
Instant Color Filters. The goal is simple toggle selected files with two different colors, quickly.

Code: Select all

dir:\\<your netbios server name>\folder\*somefolder

Code: Select all

dir:\\<NetworkDriveName>\<sharedFolder>* 
?

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

Re: Toggle File Colors ?

Post by highend »

I wouldn't do that with instant colorfilters, at least not for selected items (they are not bound to a specific folder / item type)

A version that uses labels:

Code: Select all

    $label1 = 1; // Red
    $label2 = 4; // Green

    $label1List = "";
    $items = get("SelectedItemsPathNames", "|");
    $tags = tagitems(, , , 1);
    while ($i++ < gettoken($items, "count", "|")) {
        if (gettoken($tags, $i, "|") == $label1) { $label1List = $label1List . gettoken($items, $i, "|") . "|"; }
    }
    if ($label1List) { tagitems(, $label2, $label1List); }
    $label2List = formatlist($items, "F", , "!$label1List");
    if ($label2List) { tagitems(, $label1, $label2List); }
Why does that look so complicated? Because it's much faster to use tagitems on a bunch of files only once instead
for each and every single file...
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Toggle File Colors ?

Post by CookieMonster »

The above code works on single files as well ?

I placed the code in a button that is to be executed by the right mouse; nothing happens ?

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

Re: Toggle File Colors ?

Post by highend »

The above code works on single files as well ?
Ofc
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Toggle File Colors ?

Post by CookieMonster »

I created a button in the toolbar which should work when right clicking on a file, as the script was placed within the OnRightClick for the button; instead windows default context menu appears ?

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

Re: Toggle File Colors ?

Post by highend »

A button's script should be fired when you click on a file in the list pane?
You have to right-click the button to fire the script^^
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Toggle File Colors ?

Post by CookieMonster »

A button's script should be fired when you click on a file in the list pane?
You have to right-click the button to fire the script^^
I was able to label the file color to red; although I wasn't able to toggle between red, green and off when right clicking on the button to launch the script per file ?

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

Re: Toggle File Colors ?

Post by highend »

and off
That was never a requirement^^
How can I toggle files between two different colors ?

Code: Select all

    $label1 = 1; // Red
    $label2 = 4; // Green

    $labels = ""; $labels1 = ""; $labels2 = "";
    $items = get("SelectedItemsPathNames", "|");
    $tags = tagitems(, , , 1);
    while ($i++ < gettoken($items, "count", "|")) {
        switch (gettoken($tags, $i, "|")) {
            case $label1:
                $labels1 = $labels1 . gettoken($items, $i, "|") . "|"; break;
            case $label2:
                $labels2 = $labels2 . gettoken($items, $i, "|") . "|"; break;
            case default:
                $labels = $labels . gettoken($items, $i, "|") . "|";
        }
    }
    if ($labels)  { tagitems(, $label1, $labels); }
    if ($labels1) { tagitems(, $label2, $labels1); }
    if ($labels2) { tagitems(, "", $labels2); }
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: Toggle File Colors ?

Post by CookieMonster »

Works Perfectly, thanks :)

Post Reply