Drag the downloaded file to the list under Preferences / Toolbars / Scripts.
You will then find the Level column in Folder Options, in the Script category. (You can also right-click the column header, then choose Columns > Scripts > Level.)
Requires DOpus 11.5.1 or later
Script Code:
The contents of the .js.txt file above are reproduced below, for reference:
// The OnInit function is called by Directory Opus to initialize the script add-in
function OnInit(initData) {
// Provide basic information about the script by initializing the properties of the ScriptInitData object
initData.name = "Flat View Level Column";
initData.desc = "Adds column that shows folder depth level for flat view";
initData.copyright = "2014 wowbagger";
initData.min_version = "11.5.1"
initData.version = "1.3";
initData.default_enable = true;
var cmd = initData.AddColumn();
cmd.name = "FlatViewLevel"
cmd.method = "OnFlatViewLevel";
cmd.type = "number";
cmd.label = "Level";
cmd.autogroup = true;
cmd.justify = "left";
}
// Implement the OnFlatViewLevel column (this entry point is an OnScriptColumn event).
function OnFlatViewLevel(scriptColData) {
var itemPath = scriptColData.item.realpath;
// Remove Tab path from item path
var diff = itemPath.pathpart.replace(scriptColData.tab.path, "");
// Count number of folder
var count = diff.split("\\");
// Disaply value
scriptColData.value = count.length -1;
}
It's probably not a good idea to keep copying the sample "Is Modified" column verbatim, since that has some stuff in it that is really only specific to that column.
E.g. in Advanced Find, it sets the match list to either "Yes" or "No" but for this column it would make more sense to treat it as a number (set the type to "number") which would allow searching for all level 5 files, for example.
Also the "autorefresh" flag for makes no sense for this column since the file changing doesn't change what level it's stored in.
Anyway it's just an observation You can use the New Script helper to create an empty template script that adds columns without all the "baggage" of the example.
Many thanks for this...
But I have a problem, I copy script, enable it in Prefs, but I can not add 'Level' column. There is no "Script" column category in folder option.
Interesting, This script uses min_version = "11.5.1" to prevent it from loading on earlier version, but that should not impact you.
Can you see the script named Flat View Level Column in the config?
Is it enabled?
Are there any errors in the logs?