a script: select empty folders

I have searched here ,but can't find useful information about selecting empty folders.
I mean empty folder (there is not a item in it), not a folder whose size is is equal to 0.

so,I make a script below:

function OnClick(clickData)
{
var cmd = DOpus.Create.command;
var dirs = clickData.func.sourcetab.selected_dirs;
if(dirs.count == 0) //if no folder is selected
dirs = clickData.func.sourcetab.dirs;//handle all folders in the current directory
cmd.ClearFiles(); //clear all files selected
for (var eSel = new Enumerator(dirs); !eSel.atEnd(); eSel.moveNext())
{
var dir = eSel.item();
if(!dir.is_junction && !dir.is_symlink){
var dirEnum = DOpus.FSUtil.ReadDir(dir.RealPath);
if(dirEnum.error==18){//when cannot access a folder,error=5;when a folder is empyt, error=18
//DOpus.Output(dirEnum.error);
//DOpus.Output(dir);
cmd.AddFile(dir);
}}
}
cmd.RunCommand("Select FROMSCRIPT DESELECTNOMATCH");
}

You can make a button to use this jscript.

4 Likes