RemoveEmptyColumns removes all columns from the file display that are empty for all selected items.
Example 1
Example 2
function OnInit(initData) {
initData.name = 'RemoveEmptyColumns';
initData.version = '2023-03-12';
initData.url = 'https://resource.dopus.com/t/removeemptycolumns/43929';
initData.desc = 'RemoveEmptyColumns';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnAddCommands(addCmdData) {
var cmd = addCmdData.AddCommand();
cmd.name = 'RemoveEmptyColumns';
cmd.method = 'OnRemoveEmptyColumns';
}
function OnRemoveEmptyColumns(scriptCommandData) {
var cmd = scriptCommandData.func.command;
var tab = scriptCommandData.func.sourcetab;
var fsu = DOpus.FSUtil();
var stt = DOpus.Create().StringTools();
cmd.deselect = false;
if (tab.selected.count == 0) return;
// cmd.RunCommand('Set UTILITY=otherlog');
// DOpus.ClearOutput();
var map = DOpus.Create().Map();
// Some col labels can automatically mapped to col names...
for (var e = new Enumerator(tab.format.columns); !e.atEnd(); e.moveNext()) {
var col = e.item();
map(col.label.toLowerCase()) = col.name;
}
// ... some need to be defined manually:
map('#') = 'index';
map('access date') = 'accesseddate';
map('access time') = 'accessedtime';
map('accessed') = 'accessed';
map('attr') = 'attr';
map('bitrate') = 'mp3bitrate';
map('bits') = 'picdepth';
map('channel') = 'channel';
map('comments') = 'comments';
map('created') = 'created';
map('creation date') = 'createddate';
map('creation time') = 'createdtime';
map('date') = 'modifieddate';
map('disc') = 'mp3disc';
map('document created') = 'doccreateddate';
map('encoder') = 'mp3encodingsoftware';
map('ext') = 'ext';
map('files (total)') = 'filecounttotal';
map('files') = 'filecount';
map('folders (total)') = 'dircounttotal';
map('folders') = 'dircount';
map('fourcc') = 'fourcc';
map('hd') = 'ishd';
map('modified') = 'modified';
map('name') = 'name';
map('relative created') = 'cdaterel';
map('relative modified') = 'daterel';
map('relative size on disk') = 'disksizerel';
map('relative size') = 'sizerel';
map('repeat') = 'isrepeat';
map('res x') = 'picresx';
map('res y') = 'picresy';
map('samples') = 'mp3samplerate';
map('size on disk') = 'disksize';
// map('size on disk') = 'disksizeauto';
// map('size on disk') = 'disksizekb';
map('size') = 'sizeauto';
map('station') = 'station';
map('status') = 'status';
map('time') = 'modifiedtime';
map('title') = 'mp3title';
map('track') = 'mp3track';
map('uncompressed') = 'uncompressedsize';
var tmpFile = fsu.GetTempFilePath();
cmd.RunCommand('Print FOLDER=selected AS=tab FLATVIEW=no QUIET TO="' + tmpFile + '"');
var fileDisplay = DOpus.Create().Vector();
for (var e = new Enumerator(DOpus.Create().Vector(stt.Decode(fsu.GetItem(tmpFile).Open().Read(), 'utf8').split('\r\n'))); !e.atEnd(); e.moveNext()) {
var item = e.item();
if (item.length == 0) continue;
fileDisplay.push_back(DOpus.Create().Vector(item.split('\t')));
}
var cmdLine = '';
for (var k = 0; k < fileDisplay(0).length; k++) {
var len = 0;
for (var j = 1; j < fileDisplay.length; j++) {
len += fileDisplay(j)(k).length;
}
if (len != 0) continue;
var label = fileDisplay(0)(k).toLowerCase();
if (map.exists(label)) {
cmdLine += map(label) + ',';
} else {
DOpus.Output(label + '\tnot found');
}
}
if (cmdLine == '') return;
cmdLine = 'Set COLUMNSREMOVE="' + cmdLine.slice(0, -1) + '"';
// DOpus.Output(cmdLine);
cmd.RunCommand(cmdLine);
}
Save CommandRemoveEmptyColumns.js.txt to
%appdata%\GPSoftware\Directory Opus\Script AddIns
and add the new command to a button, hotkey, context menu, etc. like any built-in command.