Last update: 2024-04-30
- Simplified installation
- Added configuration dialog
- Added toolbar
- Merged script files
- Enhanced logging/debugging
- Automatic removal of temp files
This add-in generates a custom column EverythingFolderSize that uses Everything to display folder sizes.
Opus 12 will display folder sizes almost instantaneously, just like Opus 13.
This functionality (and more) is natively available in Opus 13. Users of Opus 13 can benefit from this add-in if they want to try out other versions of Everything (1.5 alpha or any portable installation) or need a "second opinion".
Keep in mind that both the script and Everything use caches for the folder sizes. While refreshing these caches is typically fast and reliable, it's crucial to check with Opus' internal functions before performing any critical actions, such as deletion, based on the values in the column.
How to set up and use
Save EverythingFolderSize.dop to ↓
%appdata%\GPSoftware\Directory Opus\Buttons
and ColumnEverythingFolderSize.js.txt to ↓
%appdata%\GPSoftware\Directory Opus\Script AddIns
If you are upgrading from a 2023 version, remove EventUpdateEverythingFolderSize.js.txt.
Turn on the EverythingFolderSize toolbar with
Toolbar NAME=EverythingFolderSize TOGGLE
or via the Customize dialog.
Download both Everything and Everything Command-line Interface.
Install Everything and unpack es.zip.
If you run Everything 1.4:
- Copy es.exe to
/programfiles\Everything
- Check Index folder size in Everything Options
If you run Everything 1.5a:
- Copy es.exe to
/programfiles\Everything 1.5a
- Add a line (or change)
alpha_instance=0
inEverything-1.5a.ini
.
If you run Everything 1.5a or a Portable Installation:
- Click the Configuration button and update the path to es.exe. Any notation Opus understands is fine.
Click the EverythingFolderSize button to toggle the column.
(Optional) The toolbar comes with two buttons (v12 and v13) that turn the script on and off. Remove the one that doesn't match your version.
Troubleshooting
Does Everything work on its own? Are the indexes ok?
Refresh the file display (F5).
Click the Configuration button and set the logging to Standard. Turn the script off and on. Check the log.
If the script is disabled, the column will keep displaying the last received values, and any changes will not be reflected.
If the column fails to receive valid data from Everything, it will remain empty.
Things you might enjoy reading
How to use buttons and scripts from this forum
The script's inner workings
JScript
function OnInit(initData) {
initData.name = 'EverythingFolderSize';
initData.version = '2024-04-30';
initData.url = 'https://resource.dopus.com/t/everythingfoldersize-use-everything-to-calculate-folder-sizes/44281';
initData.desc = 'Use Everything to display folder sizes';
initData.default_enable = true;
initData.min_version = '12.0';
initData.config_desc = DOpus.Create().Map();
initData.config_groups = DOpus.Create().Map();
initData.config_desc('exeES') = 'Enter full path to es.exe';
initData.config_groups('exeES') = '1 - Paths';
initData.config.exeES = '/programfiles\\Everything\\es.exe';
// initData.config.exeES = '/programfiles\\Everything 1.5a\\es.exe';
// Everything 1.4: Check "Index folder size" in Tools-Options-Indexes
// Everything 1.5: Everything-1.5a.ini needs to contain this line: alpha_instance=0
initData.config_desc('colType') = 'Set column type';
initData.config_groups('colType') = '2 - Columns';
initData.config.colType = DOpus.Create.Vector(0,
'size',
'number');
initData.config_desc('logLevel') = 'Set level of logging';
initData.config_groups('logLevel') = '3 - Logging';
initData.config.logLevel = DOpus.Create.Vector(0,
'none',
'standard',
'max');
}
function OnAddColumns(addColData) {
var col = addColData.AddColumn();
col.name = 'EverythingFolderSize';
col.header = 'EFS';
col.method = 'OnColumn';
col.justify = 'right';
col.type = Script.config.colType ? 'number' : 'size';
col.autorefresh = 2;
var exeES = fsu.Resolve(Script.config.exeES);
if (fsu.Exists(exeES)) {
Log(1, 'exeES: ' + exeES);
} else {
Log(1, 'exeES: ' + exeES);
Log(1, ' <font color=#FF0000>File not found!</font>');
}
if (!fsu.Exists(exeES.pathpart + '\\Everything.exe') &&
!fsu.Exists(exeES.pathpart + '\\Everything64.exe')) {
Log(1, ' <font color=#FF0000>Everything.exe/Everything64.exe not found!</font>');
}
Log(1, 'logLevel: ' + Script.config.logLevel);
Log(1, 'colType: ' + Script.config.colType);
}
function OnColumn(scriptColData) {
var item = scriptColData.item;
if (item.is_dir) {
if (item.path.drive == 0) return;
var dirVar = 'EFS"' + item + '"';
if (!DOpus.vars.Exists(dirVar)) return;
scriptColData.value = DOpus.vars.Get(dirVar);
} else {
scriptColData.value = item.size;
}
}
function OnOpenTab(openTabData) {
if (!openTabData.tab) {
Log(1, 'OnOpenTab: !openTabData.tab is true');
return;
}
if (openTabData.tab == undefined) {
Log(1, 'OnOpenTab: openTabData.tab == undefined');
return;
}
cmd.SetSourceTab(openTabData.tab);
if (!cmd.IsSet('Set COLUMNSTOGGLE=scp:EverythingFolderSize/EverythingFolderSize')) {
Log(1, 'OnOpenTab: No column "EverythingFolderSize" in this file display... nothing to do!');
return;
}
if (!openTabData.tab.path) {
Log(1, 'OnOpenTab: !openTabData.tab.path is true');
return;
}
if (openTabData.tab.path == undefined) {
Log(1, 'OnOpenTab: openTabData.tab.path == undefined');
return;
}
if (!String(openTabData.tab.path)) {
Log(1, 'OnOpenTab: <font color=#FF0000>Empty path!</font>');
return;
}
Log(1, 'OnOpenTab: <font color=#00FF00>Calling QueryEverything...</font>');
QueryEverything(openTabData.tab.path);
Log(1, 'OnOpenTab: <font color=#00FF00>... done!</font>');
}
function OnBeforeFolderChange(beforeFolderChangeData) {
if (!beforeFolderChangeData.tab) {
Log(1, 'OnBeforeFolderChange: no beforeFolderChangeData.tab');
return;
}
cmd.SetSourceTab(beforeFolderChangeData.tab);
if (!cmd.IsSet('Set COLUMNSTOGGLE=scp:EverythingFolderSize/EverythingFolderSize')) {
Log(1, 'OnBeforeFolderChange: No column "EverythingFolderSize" in this file display... nothing to do!');
return;
}
if (!beforeFolderChangeData.path) {
Log(1, 'OnBeforeFolderChange: no beforeFolderChangeData.path');
return;
}
if (beforeFolderChangeData.path.drive == 0) {
Log(1, 'OnBeforeFolderChange: beforeFolderChangeData.path.drive == 0');
return;
}
if (!String(beforeFolderChangeData.path)) {
Log(1, 'OnBeforeFolderChange: <font color=#FF0000>Empty path!</font>');
return;
}
Log(1, 'OnBeforeFolderChange: Calling QueryEverything...');
QueryEverything(beforeFolderChangeData.path);
}
function QueryEverything(path) {
var exeES = fsu.Resolve(Script.config.exeES);
if (!fsu.Exists(exeES)) {
Log(1, 'exeES: ' + exeES);
Log(1, ' <font color=#FF0000>File not found!</font>');
return;
}
var expPath = fsu.GetTempFilePath();
var cmdLine = '"' + exeES + '"' +
' -size' +
' -no-header' +
' -export-csv "' + expPath + '"' +
' -parent "' + path + '"' +
' /ad';
Log(1, cmdLine);
wsh.Run(cmdLine, 0, true);
var expFile = fsu.GetItem(expPath).Open();
var arr = stt.Decode(expFile.Read(), 'utf8').split('\r\n');
expFile.Close();
var re = /(\d+),(.*)/;
for (var i = 0; i < arr.length; i++) {
var line = arr[i].match(re);
if (!line) continue;
if (line.length != 3) continue;
var size = line[1];
var dirVar = 'EFS' + line[2];
DOpus.vars.Set(dirVar, size);
Log(2, dirVar + '\t' + size);
}
if (!Script.config.logLevel) {
cmd.RunCommand('Delete' +
' FILE="' + expPath + '"' +
' QUIET' +
' NORECYCLE');
// DOpus.Output('Deleted: ' + expPath);
}
}
function Log(level, str, time) {
var logLevel = Script.config ? Script.config.logLevel : 2;
if (!logLevel) return;
if (!level) return;
if (level > logLevel) return;
if (time) {
var currTime = DOpus.Create().Date();
str = padTime(currTime + currTime.ms - time - time.ms) + ' ' + str;
}
DOpus.Output(str);
}
var cmd = DOpus.Create().Command();
var stt = DOpus.Create().StringTools();
var fsu = DOpus.FSUtil();
var wsh = new ActiveXObject('WScript.Shell');