A button check and show status column if there is at least one file/folder has status

I want to create a button check status column if there is at least one file/folder has status

1- if there is a file / folder in the currently focused lister has status (impotant / flagged / complete / etc.), show the status column

2- otherwise, hide the status column

Could you please help ?

You could do it using scripting but it would be fairly involved. Why not just toggle the column on to see if anything is in it, then toggle it off if it's not needed? You could make the button turn on the column and sort by it at the same time to quickly see if anything has status icons.

I prefer Dopus automatically detects and shows label column when navigating a folder instead. It'd be awesome if it's a feature in the version 13.
:blush:

1 Like

i agree. it would be great if the status column automatically appeared IF the directory had any items with label or status icon assigned. ive been digging thru the setting for a week and scrathing my head trying to figure out how to create an automatic filter for this. alas im just not a not natural at scripting.

i put the status column next to the name, otherwise if its empty i dont want to loose the space. .... or better yet, i just now thought of this, it would be nice and fun to have the empty column cell itself act as button that would open a context menu of just the labels\status ive been creating. ....now im getting carried away. ;-}

on a side note to creating status labels, i wish there were a what to create new\custom category related the to the type of media in creating them for. colors, status, and uncategorized are predefined.

^^^^^^ nevermind of that last paragraph. 1 minute after posting it i realized you just have manually type an new category name in the text\dropdown box.

Here's a little script that should do what you want.

function OnInit(initData) {
    initData.name = 'AddRemoveLabelColumns';
    initData.version = '2024-01-10';
    initData.default_enable = true;
    initData.url = 'https://resource.dopus.com/t/a-button-check-and-show-status-column-if-there-is-at-least-one-file-folder-has-status/40448/5';
    initData.min_version = '12.0';
}

function OnAfterFolderChange(afterFolderChangeData) {
    if (!afterFolderChangeData.result) return;
    var tab = afterFolderChangeData.tab;
    var cmd = DOpus.Create().Command();
    cmd.deselect = false;
    cmd.SetSourceTab(tab);
    var hasLabels = false;

    for (var e = new Enumerator(tab.all); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        if (!item.Labels().count) continue;
        hasLabels = true;
        break;
    }

    if (hasLabels) {
        cmd.RunCommand('Set COLUMNSADD=status(!,a,0)');
        cmd.RunCommand('Set COLUMNSADD=label(!,a,0)');
    } else {
        cmd.RunCommand('Set COLUMNSREMOVE=status(!,a,0)');
        cmd.RunCommand('Set COLUMNSREMOVE=label(!,a,0)');
    }
}

Save EventAddRemoveLabelColumns.js.txt to   ↓

%appdata%\GPSoftware\Directory Opus\Script AddIns

How to use buttons and scripts from this forum

1 Like

Keep in mind that checking the whole folder for labels may result in slower performance, since it's not usually done (labels are only calculated as each file is displayed for the first time, i.e. when you scroll down).

If the labels are simple wildcards or similar then it may not be a big deal, but if you have complex labels that test things like file content or script columns then it might be different.

Which isn't to say "don't do that", just that if you see performance issues then you might want to limit which folders this is done in to avoid doing it in places it isn't needed or takes too long.

2 Likes

For those wanting an on-the-fly visual test of the existence of a status label, create a Column Header Context Menu entry using the following button:

Add Status Column Toggle.dcf (342 Bytes)

Place the mouse to the right of the column location where the Status column should be placed, right click and select the toggle. This also sorts on the Status column to bring any existing status to the the top. Right click on the Status column to toggle the column off.

thank you! this is awesome. it is working, thou it placing the column at the end of the lister so i have to go scrolling for it.

and to leo... you are are right. in my movies drive with large files it is indeed slowing down to scan the 2tb folder.

You have full control over the position:

Set