Hi'
I don't know if that's what you're looking for (i.e. if by "color" you mean "color labels").
This is just an excerpt of a custom button I use (which has even more filters), so I post it
as is, I didn't try to optimize it.
It offers filtering by:
- color labels
- modified dates (hours, days)
- created dates
- size
Notes:
• The first "Filter Labeled Items" has two functions:
- if no item (or a non labeled item) is selected, then it will filter the view to only show all labeled items
- if a labeled item is selected, then it will filter the view to only show same-label items
-> if you want to filter only specific labels, you can change or add
selfilter lines. For example, I left the one I use with "(" (my main color labels have parenthesis in their name), and I added the second selfilter with "e" (by default, all color label names contain "e").
• By personal preference, the "Filter Modified..." or "Filter Created..." are based on hours - so "Modified Today" means "during the last 24 hours".
• Change the icons to the ones that suit you.
Though if that may be of interest to some, I could post my full "Filter" button with working generic icons.
Hope you enjoy it,
Flux
---------
Code: Select all
"Filter Labeled Items|:findlabel"
$mylabel=report("{Label}", 1);
if (get('CountSelected') != 1) || !($mylabel) {
selfilter "(", , "Label"; selfilter "e", , "Label", 1;
} else {
selfilter $mylabel, , "Label";
}
if (get('CountSelected') != 0) {
#359;
#251;
status("LABEL [".$mylabel."] items filtered");
} else {
status("No LABELED items to filter", "883333", stop);
}
-
"Filter Modified Today|[Icons]\Date.ico"
global $g_myhours; $g_myhours=24;
sub "_Filter Modified";
"Filter Modified The Last 3 Days"
global $g_myhours; $g_myhours=72;
sub "_Filter Modified";
"Filter Modified This Week"
global $g_myhours; $g_myhours=168;
sub "_Filter Modified";
"Filter Modified The Last 6 Hours"
global $g_myhours; $g_myhours=6;
sub "_Filter Modified";
"Filter Size > 100 MB|[Icons]\Size.ico"
global $g_mysize; $g_mysize=100;
sub "_Filter Size";
"Filter Size > 10 MB"
global $g_mysize; $g_mysize=10;
sub "_Filter Size";
-
"Filter Created Today|[Icons]\Date.ico"
global $g_myhours; $g_myhours=24;
sub "_Filter Created";
"Filter Created This Week"
global $g_myhours; $g_myhours=168;
sub "_Filter Created";
"_Filter Modified"
global $g_myhours;
$fileinfo=report("{Modified};{Name}|");
$todaylist="";
foreach($myitem, $fileinfo, "|") {
$filedate=gettoken($myitem, 1, ";");
$filename=gettoken($myitem, 2, ";");
if ($filedate!="") {if(datediff($filedate, , h) < $g_myhours) {$i++;$todaylist=$todaylist.$filename."|"}}
}
if $i > 0 {
$todaylist=replacelist ($todaylist, "[;]", "", ";");
selectitems $todaylist;
$todaylist=regexreplace($todaylist, "\s#.*?\|", "|"); // Remove #... for filter
filter "By Date" $todaylist;
#251;
status("Filtered ".$i." item(s) modified in the last ".$g_myhours." hours");
} else {
status("No items modified in the last ".$g_myhours." hours", "883333", stop);
}
"_Filter Created"
global $g_myhours;
$fileinfo=report("{Created};{Name}|");
$todaylist="";
foreach($myitem, $fileinfo, "|") {
$filedate=gettoken($myitem, 1, ";");
$filename=gettoken($myitem, 2, ";");
if ($filedate!="") {if(datediff($filedate, , h) < $g_myhours) {$i++;$todaylist=$todaylist.$filename."|"}}
}
filter "By Date" $todaylist;
if $i > 0 {
status("Filtered ".$i." item(s) created in the last ".$g_myhours." hours");
} else {
status("No items created in the last ".$g_myhours." hours", "883333", stop);
}
"_Filter Size"
global $g_mysize;
$fileinfo=report("{Size};{Name}|");
$todaylist="";
foreach($myitem, $fileinfo, "|") {
$filename=gettoken($myitem, 2, ";");
$filesize=gettoken($myitem, 1, ";");
$filesize=replace(gettoken($filesize, 1, " MB"), ",", ".");
if ($filesize > $g_mysize) {$i++;$todaylist=$todaylist.$filename."|"}}
}
if $i > 0 {
$todaylist=replacelist ($todaylist, "[;]", "", ";");
selectitems $todaylist;
filter "By Size" $todaylist;
#251;
if (get('View')!=0) {#302;}
sortby "s";
status("Filtered ".$i." item(s) bigger than ".$g_mysize." MB");
} else {
status("No items bigger than ".$g_mysize." MB", "883333", stop);
}
[/size]||