// Called by Directory Opus to initialize the script function OnInit(initData) { initData.name = "HasJpegColumn"; initData.version = "1.0"; initData.copyright = "(c) 2017 Leo Davidson"; initData.url = "https://resource.dopus.com/viewtopic.php?f=3&t=27784"; initData.desc = "Indicates if video file has matching .jpg file."; 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; } // Implement the HasJPEG column function OnHasJPEG(scriptColData) { if (scriptColData.item.is_dir) { return; } var groups = scriptColData.item.groups; if (typeof groups != "object") { return; } var movie = false; for (var i = 0; i < groups.count; ++i) { if (groups(i) == "Movies") { movie = true; break; } } if (!movie) { return; } var resPath = DOpus.FSUtil.Resolve(scriptColData.item.realpath); if (DOpus.FSUtil.Exists(resPath + ".jpg")) { scriptColData.value = "Yes"; scriptColData.sort = 0; // Sort Yes before No. } else { scriptColData.value = "No"; scriptColData.sort = 1; // Sort Yes before No. } }