Page 1 of 2
Change color based on content of folder?
Posted: 20 Oct 2017 14:51
by mrbosco
Is there a way to change the color of the folder if a file within that folder has been recently updated?
Re: Change color based on content of folder?
Posted: 20 Oct 2017 15:12
by highend
As long as that file is in the selected folder (and not further down in a subfolder of it)?
If the file is modified, the modified timestamp of that folder changes as well. So you
could define several color filters with different colors for different modified ranges...
Re: Change color based on content of folder?
Posted: 20 Oct 2017 15:20
by mrbosco
What if the file is a subfolder or two down?
Re: Change color based on content of folder?
Posted: 20 Oct 2017 15:33
by highend
colorfilters don't look into single changes for arbitrary files somewhere deep inside a folder structure so
afaik there is no automatism to change the color (at least not if the folder structure is not 100% static).
Scripting could do it but it would require user interaction to fire it... Or an external .ahk tool that
monitors folders and sends a script to that XY instance to change the label for that folder...
Re: Change color based on content of folder?
Posted: 20 Oct 2017 15:51
by mrbosco
Can you please provide a sample script?
BTW, I don't necessarily need the color of the folder to change.
If I had a way of displaying only folders whose files nested a few layers down have changed recently that would be just as good.
Re: Change color based on content of folder?
Posted: 20 Oct 2017 16:09
by highend
Shows the folders from the current active pane that have a file modified in the last
7 days in a new paperfolder... Modify it as you need
Code: Select all
$folders = listfolder(, , 2, <crlf>);
$modifiedFiles = quicksearch("ageM: <= 7 d /limitperdir=1");
$paperContent = "";
foreach($folder, $folders, <crlf>, "e") {
$escaped = regexreplace($folder, "([\\.+(){\[^$])", "\$1");
if (regexmatches($modifiedFiles, $escaped . "\\")) {
$paperContent = $paperContent . $folder . <crlf>;
}
}
if ($paperContent) { paperfolder("Modified", $paperContent); }
Re: Change color based on content of folder?
Posted: 20 Oct 2017 16:36
by mrbosco
I'll give it a try.
Thanks!
Re: Change color based on content of folder?
Posted: 26 Oct 2017 23:30
by mrbosco
The script works great. However, I'm new to scripting and trying to understand exactly how it works.
Can you please explain what each of the following lines do?
Code: Select all
$escaped = regexreplace($folder, "([\\.+(){\[^$])", "\$1");
Code: Select all
if (regexmatches($modifiedFiles, $escaped)) {
Thanks,
Howie
Re: Change color based on content of folder?
Posted: 27 Oct 2017 01:28
by highend
I've removed the full quote of the script and added code tags to the two lines in
your posting...
Code: Select all
$escaped = regexreplace($folder, "([\\.+(){\[^$])", "\$1");
I'm replacing all meta characters for the current folder in the loop
with a leading backslash followed by the metacharacter because
I need the escaped path for the following if statement
Code: Select all
if (regexmatches($modifiedFiles, $escaped)) {
The regexmatches requires a regex pattern (done in the previous
explanation) and I'm checking here if the folder exists as a part
in the modified files list
Re: Change color based on content of folder?
Posted: 27 Oct 2017 15:15
by mrbosco
Thank you!
Re: Change color based on content of folder?
Posted: 30 Oct 2017 14:11
by mrbosco
Seems to be an issue with the script.
If I have two folders ABC and ABCD and a file is updated within ABCD, both folders ABC and ABCD are in the paper folder even though nothing has been updated in folder ABC.
Re: Change color based on content of folder?
Posted: 30 Oct 2017 14:18
by highend
Screenshot of both folders in the list (last modified date column must be visible as well)?
Re: Change color based on content of folder?
Posted: 30 Oct 2017 18:10
by mrbosco
I changed the script to
$folders = listfolder(, , 2, <crlf>);
$modifiedFiles = quicksearch("ageM: <= 1 h /limitperdir=1");
$paperContent = "";
foreach($folder, $folders, <crlf>, "e") {
$escaped = regexreplace($folder, "([\\.+(){\[^$])", "\$1");
if (regexmatches($modifiedFiles, $escaped)) {
$paperContent = $paperContent . $folder . <crlf>;
}
}
if ($paperContent) { paperfolder("Modified", $paperContent); }
since I created the folder earlier in the day.
Folder ABC is empty
Folder ABCD has one recently modified file in it.
The script produces both folders ABC and ABCD
Re: Change color based on content of folder?
Posted: 30 Oct 2017 18:43
by highend
Replace
Code: Select all
if (regexmatches($modifiedFiles, $escaped)) {
with
Code: Select all
if (regexmatches($modifiedFiles, $escaped . "\\")) {
Re: Change color based on content of folder?
Posted: 30 Oct 2017 20:38
by mrbosco
Thanks!