function OnInit(initData) { initData.name = 'RemoveEmptyColumns'; initData.version = '2023-10-05'; 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'; cmd.icon = 'script'; } 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; var map = DOpus.Create().Map(); // Some column labels can be mapped to column names automatically... 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('audio streams') = 'audiocount'; map('bitrate') = 'mp3bitrate'; map('bits') = 'picdepth'; map('blake3 checksum') = 'blake3sum'; map('channel') = 'channel'; map('comments') = 'comments'; map('crc32 checksum') = 'crc32sum'; map('created') = 'created'; map('creation date') = 'createddate'; map('creation time') = 'createdtime'; map('date') = 'modifieddate'; map('description') = 'imagedesc'; 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('hdr') = 'hdrtypes'; map('instructions') = 'instructions'; map('location') = 'pathrel'; map('md5 checksum') = 'md5sum'; 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('sha-1 checksum') = 'shasum'; map('sha-256 checksum') = 'sha256sum'; map('sha-512 checksum') = 'sha512sum'; 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('subtitles') = 'subtitlecount'; map('time') = 'modifiedtime'; map('title') = 'mp3title'; map('track') = 'mp3track'; map('uncompressed') = 'uncompressedsize'; map('video streams') = 'videocount'; 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'))); } if (fileDisplay.empty) { DOpus.Output('Could not print File Display!?'); return; } 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) continue; var label = fileDisplay(0)(k).toLowerCase(); if (map.exists(label)) { if (cmdLine) cmdLine += ','; cmdLine += map(label); } else { DOpus.Output('Label not found: ' + label); } } if (!cmdLine) return; cmdLine = 'Set COLUMNSREMOVE="' + cmdLine + '"'; DOpus.Output(cmdLine); cmd.RunCommand(cmdLine); }