Page 1 of 2
relative age
Posted: 18 Jul 2018 19:45
by silentDriver
Hello everyone,
I've been a user for years of this wonderful software, and its the first time i couldn't solve an issue that has not appeared before on the forum.
I'm trying to highlight in some way the newest (or oldest) file from a folder. I thought i could use color filter or age graphics but they work relative to "today", I would like to highlight relative to the contents of the folder, for example the newest file could be from last year.
I know the easy way is to sort by date descending, but I need to keep the sort by name to compare related files.
thanks and I hope my english is good enough

.
Re: relative age
Posted: 18 Jul 2018 20:01
by Marco
Wouldn't secondary sorting help you?
Re: relative age
Posted: 18 Jul 2018 20:23
by silentDriver
Marco wrote:Wouldn't secondary sorting help you?
indeed it does help, and it is afunction i never used before! thank you very much

, but for the sake of a visual cue is it possible to highlight or use the age graphic for this?
Re: relative age
Posted: 18 Jul 2018 20:23
by highend
I'd use a script...
Code: Select all
// Labels are case-sensitive!
$labelColorNewest = "Green";
$labelColorOldest = "Red";
$keyModifier = 1; // Shift key
// ========================================================================
// == DO NOT CHANGE ANYTHING BELOW IF YOU DO NOT KNOW WHAT YOU ARE DOING ==
// ========================================================================
$items = report("{fullname}|{Dir 0|1}|{modified}<crlf>");
$files = regexmatches($items, "^.+\|1\|.+?(?=\r?\n|$)", <crlf>);
// -1 = Oldest file, 1 = newest file
$diffType = (<get "Shift"> != $keyModifier) ? -1 : 1;
if ($diffType == -1) { $otherDate = <date>; }
else { $otherDate = formatdate(, , "y", -218); }
$otherFile = "";
foreach($file, $files, <crlf>, "e") {
$path = gettoken($file, 1, "|");
$date = gettoken($file, 3, "|");
if (compare($date, $otherDate, "d") == $diffType) {
$otherDate = $date;
$otherFile = $path;
}
}
if ($otherFile) { tagitems("label", (($diffType == -1) ? $labelColorOldest : $labelColorNewest), $otherFile); }
In other words, if the shift key is hold when the script is executed the newest file in a directory would be colored "Green" and if the shift key
is NOT hold, the oldest file would be colored "Red"...
Re: relative age
Posted: 18 Jul 2018 21:21
by silentDriver
highend wrote:I'd use a script...
Code: Select all
// Labels are case-sensitive!
...
if ($otherFile) { tagitems("label", (($diffType == -1) ? $labelColorOldest : $labelColorNewest), $otherFile); }
In other words, if the shift key is hold when the script is executed the newest file in a directory would be colored "Green" and if the shift key
is NOT hold, the oldest file would be colored "Red"...
thank you very much, it works great!
Re: relative age
Posted: 19 Jul 2018 03:21
by jupe
@highend: Nice script!
@silentDriver: I just thought of a slight variation on it, that is if you only want the colors to be temporary (ie. in use on 1 folder at a time, 1 color at a time) you could use colorfilter() so you don't end up with a heap of labelled files everywhere in your tags.db, I made a quick modification of highends script to do it that way if it is of any interest:
Code: Select all
$labelColorNewest = "B5D74A"; // Green
$labelColorOldest = "FC7268"; // Red
$keyModifier = 1; // Shift key
// ========================================================================
// == DO NOT CHANGE ANYTHING BELOW IF YOU DO NOT KNOW WHAT YOU ARE DOING ==
// ========================================================================
$items = report("{fullname}|{Dir 0|1}|{modified}<crlf>");
$files = regexmatches($items, "^.+\|1\|.+?(?=\r?\n|$)", <crlf>);
// -1 = Oldest file, 1 = newest file
$diffType = (<get "Shift"> != $keyModifier) ? -1 : 1;
if ($diffType == -1) { $otherDate = <date>; }
else { $otherDate = formatdate(, , "y", -218); }
$otherFile = "";
foreach($file, $files, <crlf>, "e") {
$path = gettoken($file, 1, "|");
$date = gettoken($file, 3, "|");
if (compare($date, $otherDate, "d") == $diffType) {
$otherDate = $date;
$otherFile = $path;
}
}
if ($otherFile) { colorfilter("name f:$otherFile>000000," . (($diffType == -1) ? $labelColorOldest : $labelColorNewest));}
not knowing your exact usage scenario, you probably prefer using labels though anyway.
Re: relative age
Posted: 19 Jul 2018 14:26
by silentDriver
jupe wrote:@highend: Nice script!
@silentDriver: I just thought of a slight variation on it, that is if you only want the colors to be temporary (ie. in use on 1 folder at a time, 1 color at a time) you could use colorfilter() so you don't end up with a heap of labelled files everywhere in your tags.db, I made a quick modification of highends script to do it that way if it is of any interest:
Code: Select all
$labelColorNewest = "B5D74A"; // Green
$labelColorOldest = "FC7268"; // Red
$keyModifier = 1; // Shift key
...
if ($otherFile) { colorfilter("name f:$otherFile>000000," . (($diffType == -1) ? $labelColorOldest : $labelColorNewest));}
not knowing your exact usage scenario, you probably prefer using labels though anyway.
thank you jupe! Actually this works even better since I do use labels on some folders and the previous script would override those labels. I will keep both scripts, since i will often need to keed marked the files.
Re: relative age
Posted: 19 Jul 2018 15:36
by highend
since I do use labels on some folders and the previous script would override those labels. I will keep both scripts, since i will often need to keed marked the files
Why don't you use tags instead (with a custom column that looks for specific tags and colors that custom column)?
Re: relative age
Posted: 19 Jul 2018 16:35
by kunkel321
Very clever guys! Thanks!
EDIT: Icon for toolbar:

Re: relative age
Posted: 19 Jul 2018 17:32
by silentDriver
highend wrote:since I do use labels on some folders and the previous script would override those labels. I will keep both scripts, since i will often need to keed marked the files
Why don't you use tags instead (with a custom column that looks for specific tags and colors that custom column)?
yes, i'm going to try and modify your script to use tags, i'tll be a good excersice to learn the scripting language. I program often in vba to automate office work, but haven't gone deep enough on xyplorer capabilities.
Anyways, it would be really nice if xyplorer had the option to show its graphics (bars and circles) relative to the folder contents, it would be easy to spot the biggest / oldest /smaller / etc. file
Re: relative age
Posted: 23 Jul 2018 16:50
by kunkel321
I seem to remember this same idea coming up in the context of
Instant Color Filters. I think that I was the one who asked/requested/suggested, though I can't find the post now. There are several default ICFs that color by date

but they all use static date ranges. E.g.
"Created or Modified Today" ageC: d;ageM: d>FFFFFF,70B926
"Created or Modified This Week" ageC: w;ageM: w>FFFFFF,B97026
"Folders Created Recently" ageC d: <= 3 h //folders created last 3 hours>FFFF00,0073E6||ageC d: d //folders created today>FFFF80,379BFF||ageC d: w //folders created this week>FFFFFF,71B8FF
"Files Modified Recently" ageM f: <= 5 n //files modified last 5 min>FFFF00,4F831B||ageM f: <= 1 h //files modified last hour>FFFF00,63A521||ageM f: <= 24 h //files modified last 24 hours>FFFFFF,70B926
So the idea was to have a color-coding scheme that colored by relative ages. As I recall it was determined that this wasn't practical but I don't remember exactly why. For one thing, I don't think that the needed scripting can by integrated into ICF definitions. It might be nice though, if a person could (for example) highlight the oldest/newest 10% of the files/folders. (Rather than just the one oldest/newest.)
Re: relative age
Posted: 23 Jul 2018 17:39
by highend
It might be nice though, if a person could (for example) highlight the oldest/newest 10% of the files/folders.
Can be done easily by scripting as well...
Re: relative age
Posted: 24 Jul 2018 06:16
by kunkel321
highend wrote:It might be nice though, if a person could (for example) highlight the oldest/newest 10% of the files/folders.
Can be done easily by scripting as well...
How about statistical "outliers?" Like calculate the mean/average age of the items in the folder, then color-code those that are one (two?) standard deviation above or below that mean? I'm not exactly sure what the math for that would look like--but we might be able to figure it out.
Re: relative age
Posted: 25 Jul 2018 07:24
by highend
How about statistical "outliers?" Like calculate the mean/average age of the items in the folder, then color-code those that are one (two?) standard deviation above or below that mean?
Should be doable as well. When I'm back...
Re: relative age
Posted: 30 Jul 2018 12:58
by highend
Changed the whole thing a bit...
Now it is driven via a html form:
ss.png
It supports either fixed numbers or percentage values:
Valid input:
1
5
20
or
5%
20%
etc.
If you are using labels for "Type:", they are NOT cleared if
you run the script multiple times (and e.g. decrease the number
to colorize)!
If you want to change the colors or add additional ones, run the script once
(and click the "Colorize" button^^) and afterwards change the .ini file:
Colors=
line. The comments in the .ini file explain how to do it...
@kunkel321
So, average calculation isn't a problem, but how exactly do you want the <x> above / below standard deviation to work (and how should it be displayed in the form)?
Colorize files v0.1.xys