custom icons beside files ?
Posted: 12 Mar 2017 08:09
I would like to place a custom icon beside a file when it has been read or watched or semi-read etc. Is it possible to place custom icons beside file names ?
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
Code: Select all
*.*> $label = report("{Label}", "<curitem>"); $label2 = report("{Tags}", "<curitem>"); if($label2 <= "3") { tag "Green"; } elseif($label2 > "3" && $label2 <= "6") { tag "Orange"; } elseif($label2 > "6") { tag "Red"; }; if($label2 == "") { tag "1", , 1, 1; } elseif($label2 != "") { $label2++; tag "$label2", , 1, 1; }; run """<curitem>""";I assume I run the script on a folder ? If so I get an error at this line;SkyFrontier wrote:Well... I was about to suggest setting labels or tags for that same task, which I used in the past for marking most used files, but intrigued with XY being NOT able to set custom icons via script, and being off for a big while, decided to give Help a chance - and found seticons().
If you're open to a bit of sacrifice on PFA comfort due to its current implementation, later I may have something posted here.
Base solution:Code: Select all
*.*> $label = report("{Label}", "<curitem>"); $label2 = report("{Tags}", "<curitem>"); if($label2 <= "3") { tag "Green"; } elseif($label2 > "3" && $label2 <= "6") { tag "Orange"; } elseif($label2 > "6") { tag "Red"; }; if($label2 == "") { tag "1", , 1, 1; } elseif($label2 != "") { $label2++; tag "$label2", , 1, 1; }; run """<curitem>""";
Code: Select all
*.*> $label = report("{Label}", "<curitem>");highend wrote:I had some fun stress testing seticons(). 1000 files with a random pool of ~50 icons -> XYplorer just quit. Without any error message.
Ofc this will not be the case here, it's only about setting one file icon at a time.
Cleaning up isn't probably not that hard, at least with a script. A regexmatches() + a bit of string manipulation + a final seticons()
but ofc this had to be done manually from time to time...
Mh? Look at this:It seems to not support individual files' definitions, only generic 'per drive/extension/folder' ones
In my quick tests I could only change icons for externsions, not for individual files. Thanks for the tip, will bother later!highend wrote:Mh? Look at this:It seems to not support individual files' definitions, only generic 'per drive/extension/folder' ones
...
For the time being. Since highend pointed there is a way to add unique icons to unique files, I'll come up with something later (today, I hope - have to manage another something here, sorry) - not smart as the 'tags' method, but better than nothing (my idea is to swap icons based on other factors, 'tags' perhaps, since I currently don't know a way to retrieve a CFI, but you may not need these).CookieMonster wrote:I can only color files, no icons to files can be added.
Code: Select all
0.25 [<extension>].ico
0.50 [<extension>].ico
0.75 [<extension>].ico
1.00 [<extension>].ico
Translated -> Half read status0.50 [doc].ico
Code: Select all
perm $P_CFI_ClearCounter;
$clearEvery = 10;
$iconDir = "<xyicons>\states";
$states = "0.25|0.50|0.75|1.00|-|reset";
$state = popupmenu($states);
$ext = gpc(<curitem>, "ext");
if !($state) { status "No state selected, aborted!", "8B4513", "stop"; end 1==1; }
switch ($state) {
case "0.25": $icon = "$iconDir\0.25 [$ext].ico"; break;
case "0.50": $icon = "$iconDir\0.50 [$ext].ico"; break;
case "0.75": $icon = "$iconDir\0.75 [$ext].ico"; break;
case "1.00": $icon = "$iconDir\1.00 [$ext].ico"; break;
default: $icon = "";
}
// Check if the icon exists
if ($icon && exists($icon) != 1) { status "Selected icon does not exist, no icon set!", "8B4513", "stop"; end 1==1; }
$curCFIs = seticons();
$index = gettokenindex("+<curitem>>*", $curCFIs, <crlf>, "iw");
if (!$index && $state UnLikeI "reset") { seticons("+<curitem>>$icon"); } // Not in $index and "reset" wasn't selected -> Add it
elseif ($state LikeI "reset") { seticons(gettoken($curCFIs, $index, <crlf>), "d"); } // Delete CFI entry
else { seticons("+<curitem>>$icon", "r", $index); } // Replace CFI entry
$P_CFI_ClearCounter++;
if ($P_CFI_ClearCounter >= $clearEvery) {
$matches = regexmatches($curCFIs, "^\+([A-Z]:|\\\\).*?(?=\r?\n)", <crlf>);
$definitions = "";
foreach($match, $matches, <crlf>, "e") {
if (exists(regexreplace($match, "(^\+|>.+$)")) == 1) { continue; }
$definitions = $definitions . $match . <crlf>;
}
seticons($definitions, "d");
}