Easy enough:
HasFolderJpeg.js.txt (1.4 KB)
// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
var wild = DOpus.FSUtil.NewWild("*.(jpg|jpeg)", "f");
// Called by Directory Opus to initialize the script
function OnInit(initData)
{
initData.name = "HasJPEG";
initData.version = "1.0";
initData.copyright = "(c) 2019 Leo Davidson";
initData.url = "https://resource.dopus.com/t/find-folders-that-do-not-have-a-specific-file/28558/11";
initData.desc = "A column that says if a folder contains any JPG file directly below it, for use with searching.";
initData.default_enable = true;
initData.min_version = "12.0";
var col = initData.AddColumn();
col.name = "HasJPEG";
col.method = "OnHasJPEG";
col.label = "Has JPEG";
col.justify = "left";
col.autogroup = true;
col.match.push_back("Yes");
col.match.push_back("No");
}
// Implement the HasJPEG column
function OnHasJPEG(scriptColData)
{
if (!scriptColData.item.is_dir)
{
scriptColData.value = "";
return;
}
var match = false;
var dir = DOpus.FSUtil.ReadDir(scriptColData.item.realpath);
while (!match && !dir.complete)
{
var item = dir.Next();
if (item.is_dir)
{
continue;
}
if (wild.Match(item))
{
match = true;
}
}
dir.Close();
if (match)
{
scriptColData.value = "Yes";
}
else
{
scriptColData.value = "No";
}
}