Size of specific folder in status bar?

Hi everyone!
is there a way to have the status bar show the size of a specific folder I want? without it being selected or even in an open lister.
Thanks!

Use a script to get the folder size and set it as a global variable "fdrSize"?
{var:glob:fdrSize}

arghh dopus scripts is something I just can't get my head around...i tried asking chatGPT how to implement this but nothing worked...
Thanks anyway!

After installing the script, modify the directory and restart DOpus.

// Watch a folder size
// (c) 2024 Ken

// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/endpoints/redirect.php?page=scripts for development information.



// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "Watch a folder size";
	initData.version = "1.0";
	initData.copyright = "(c) 2024 Ken";
//	initData.url = "https://resource.dopus.com/c/buttons-scripts/16";
	initData.desc = "Display folder size in the Status Bar. \r\nFor Preferences / Display / Status Bar: FdrSize={var:glob:fdrSize}";
	initData.default_enable = true;
	initData.min_version = "13.0";


}

// Called when Directory Opus starts up
function OnStartup(startupData)
{
	var totalSize = getFolderSize();
	DOpus.Vars.Set("fdrSize") = totalSize;
    var fsu = DOpus.FSUtil();
    var item = "D:\\Test";
    var itemID = 007;
    fsu.WatchChanges(itemID, item, 'fdraswi');
}

// Called when a filesystem change has occurred (use FSUtil.WatchChanges to initiate)
function OnFilesystemChange(fileSystemChangeData)
{
	if (fileSystemChangeData.id != 007) return
	var totalSize = getFolderSize();
	DOpus.Vars.Set("fdrSize") = totalSize
}

function getFolderSize() {
	var totalSize = DOpus.FSUtil.NewFileSize(0);
	var folderEnum = DOpus.FSUtil.ReadDir("D:\\Test", true);
	while (!folderEnum.complete)
	{
		var folderItem = folderEnum.next;
		if (!folderItem.is_dir)
			totalSize.Add(folderItem.size);
	}
	return  Math.floor(totalSize/1024 * 100) /100 + " KB"
}

Watch a folder size.opusscriptinstall (1.1 KB)

2 Likes

thanks so much !! worked like a charm!!