# Find folders that do not have a specific file?

**URL:** <https://resource.dopus.com/t/find-folders-that-do-not-have-a-specific-file/28558>\
**Category:** Help & Support\
**Created:** [April 14, 2018, 6:33am UTC](https://resource.dopus.com/t/find-folders-that-do-not-have-a-specific-file/28558 "2018-04-14T06:33:12Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [September 3, 2019, 8:34pm UTC](https://resource.dopus.com/t/find-folders-that-do-not-have-a-specific-file/28558/12 "2019-09-03T20:34:44Z")

</div>

> [@Groovybanana](#):
>
> What I want to be able to do is locate folders that do not contain a certain file type. As an example, in my music directory, locate all folders that do not contain a .jpg file. Now, all of my album covers have different names so it would need to search with a wildcard, like \*.jpg

Easy enough:

[HasFolderJpeg.js.txt](https://resource.dopus.com/uploads/short-url/1BRIm436uDFOjzOpzfuuc653JG8.txt) (1.4 KB)

```javascript
// 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";
	}
}

```

---

_[View the full topic](https://resource.dopus.com/t/find-folders-that-do-not-have-a-specific-file/28558)._
