Label Filter - Empty Folders & Partial Temp Files In That Folder

Scripts are easy :slight_smile: This will add a column called EmptyDirExceptPart that you can then use in your filter (it will equal 1 when empty, and ignores .part files). Save the script to your /dopusdata/Script AddIns folder with a .js suffix.

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "EmptyDirExceptPart";
	initData.version = "1.0";
	initData.copyright = "(c) 2017 jpotter";
//	initData.url = "https://resource.dopus.com/viewforum.php?f=35";
	initData.desc = "";
	initData.default_enable = true;
	initData.min_version = "12.0";

	var col = initData.AddColumn();
	col.name = "EmptyDirExceptPart";
	col.method = "OnEmptyDirExceptPart";
	col.label = "EmptyDirExceptPart";
	col.justify = "left";
	col.autogroup = true;
}

// Implement the EmptyDirExceptPart column
function OnEmptyDirExceptPart(scriptColData)
{
	if (!scriptColData.item.is_dir) return;
	var readDir = DOpus.FSUtil.ReadDir(scriptColData.item);
	while (!readDir.complete) {
		var item = readDir.Next()
		if (item.is_dir || item.ext != ".part")
		{
			scriptColData.value = "0";
			return;
		}
	}
	scriptColData.value = "1";
}
1 Like