Multi Commander > Feature Requests and Suggestions

Color code folders based on empty sub-branch / MultiScript columns

(1/2) > >>

multicart:
Hello Mathias,

I am a long time user of XYplorer and am "forced" to migrate to Multi Commander because of restrictions bestowed upon me by my employer.
That said, MC seems to be nice and actively (maybe even passionately?) developed. So, the pain is already reduced.

One of the features, though, that I am very sad about to have lost, is the option to be able to color code folders based on whether their sub-branch is empty of files. Meaning, if the folder and its sub-folders (if any) do not contain any files, then color code the folder in a certain way, e.g. blue text.
Especially, when browsing a folder structure, created by someone else, this is very helpful. Sometimes also with my own folder structure.

In order to accomplish this, that logic must be accessible in the file coloring rules.
I also have an idea, already, how:

In https://forum.multicommander.com/forum/index.php/topic,4745.msg13685.html#msg13685 you mentioned:


--- Quote from: Mathias (Author) ---I have some idea about a column that gets the content to show from a MultiScript.

--- End quote ---

With such a "custom column" implemented I could (hopefully) write my own script for that column, evaluating each folders content and returning an indicator in that special column (as long as I have a variable/placeholder for the item of each line (respectively, the current line,) that I can use in that MultiScript). Then I could base my coloring rule on that column's value - as long as the coloring rules will then support such special columns.

There are other things that I already miss, but this one currently seem the most important for me.
Many thanks in advance if you were to consider it.

Kind regards,
multicart

Mathias (Author):
I got it in my list, to add support for that with the file coloring.

Might be able to do with custom columns. and then a color rule for that, like you say.

Problem is that you do not want to get a list of all sub items that are recursive. That will cause performance issue.
So you want it to return directly if it finds any files. Not sure you can do that efficient with script yet. I will check.

multicart:
Thank you.


--- Quote ---So you want it to return directly if it finds any files. Not sure you can do that efficient with script yet.
--- End quote ---
I have not yet looked at the scripting limitations. Are you saying that the script does not have a return command that you could call if it encounters a file? Seriously? Well, as I just said, I will yet have to look at the scripting. Maybe it works differently than I would expect?

Mathias (Author):

--- Quote from: multicart on November 12, 2024, 09:27:05 ---Thank you.


--- Quote ---So you want it to return directly if it finds any files. Not sure you can do that efficient with script yet.
--- End quote ---
I have not yet looked at the scripting limitations. Are you saying that the script does not have a return command that you could call if it encounters a file? Seriously? Well, as I just said, I will yet have to look at the scripting. Maybe it works differently than I would expect?

--- End quote ---

Yes you can return from script when you want.. That is not the problem.
The script commands are simpler then normal API. You can do FindFirstFile() that return first match or get all items from a folder using FindFiles(..) But it return all matched files from a path.
That is  not be optimal if the folder has MANY files, And also you need to do the subfolder check in script. and issue new FindFiles call for each folder and walk down the folder tree.
It is possible but not optimal.

What is needed is a FindFirstFile that supports going down in subfolders.
I remember that I needed a script function like that for my self too.. so the next beta that will have FindFirstFileEx that support subfolders..


Mathias (Author):
From Build 3036 (beta) there is now a new function that can be used to be able to colors folder with no files.. (subfolder are not counted as files)

It is a bit tricky and many steps to connect everything together.

Create a User defined Command
Create a Userdefined command of type MultiScript

--- Code: ---#options (AllowAsFileProp)
if(IsVariableDefined("$_FILEPROP_FILEPATH") == 0)
{
  @gvar $_FILEPROP_FILEPATH = GetSourceFocusPath();
}

@var $isEmpty = "";
@var $isFolder = IsFolder($_FILEPROP_FILEPATH);

if($isFolder)
{
    $_FILEPROP_FILEPATH = $_FILEPROP_FILEPATH  ^ "*";
   @var $found = FindFirstFileEx($_FILEPROP_FILEPATH, "SUBFOLDERS,ONLYFILENAME, IGNOREFOLDERS");
   if(!StrIsEqual($found, ""))
   {
     $isEmpty = "Empty";
   }
}

@var $_FILEPROP_DISPLAYNAME = $isEmpty;

--- End code ---

Save it.

Define a Scriptable File Property (Column in filelist)
Right click on column header and go to customize.
Click the Script button at the side to define a new Scriptable file property.
Create a new, and from the Dropdown select the MultiScript function you created before. It should be shown in the dropdown list.
Save it
Then Add That scriptable column to the columns that should be show.

Create a File Coloring Rule.
Click on color wheel icon and and Select File Coloring Rules Editor.
Add a new rules and enter a name for it. (rules are matched from top to button, so if you have multiple rules maybe you need to move it to the top so it is not overwritten by anohter rule)
And click Modify rules.
Select "Plug-in (Extended Properties)"
Add New
Then select the scriptable column you defined before
In Text matching selet "IS" and "Empty"
Then save it configure the color you want for that rule and then save it

The only current issue is that the scriptable column need to be shown for it to work.



Navigation

[0] Message Index

[#] Next page

Go to full version