GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Find folders that do not have a specific file?


#1

I would like to find all folders that DO NOT have a specific file. I tried some things, but gave up.


Select folders which (sub)folder(s) contains certain file?
#2

It can be done but would require some scripting.

We can help with some more detail:

  • What’s the filename you want to check for?
  • If folder A doesn’t contain the file directly below it, should it then look in other folders below it, or stop straight away?
  • If A doesn’t have the file, but A\B does contain the file, do you want A to be included or excluded?

#3
  1. filename is FolderArt.xmv
  2. No, there won’t be any
  3. Assuming this is dependant on #2? If yes, this doesn’t matter then.

Thanks.


#4

Download this and drop it into the list in Preferences / Toolbars / Scripts:

You can then use it like this:

Script code for reference:

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "HasFolderArt";
	initData.version = "1.0";
	initData.copyright = "(c) 2018 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/this-type-of-search-possible/28558";
	initData.desc = "Adds a column that says if a folder contains a FolderArt.xmv file, which can be used for searching.";
	initData.default_enable = true;
	initData.min_version = "12.0";

	var col = initData.AddColumn();
	col.name = "HasFolderArt";
	col.method = "OnHasFolderArt";
	col.label = "Has Folder Art";
	col.justify = "left";
	col.autogroup = true;
	col.match.push_back("Yes");
	col.match.push_back("No");
}


// Implement the HasFolderArt column
function OnHasFolderArt(scriptColData)
{
	if (!scriptColData.item.is_dir)
	{
		scriptColData.value = "";
		return;
	}

	if (DOpus.FSUtil.Exists(scriptColData.item.realpath + "\\FolderArt.xmv"))
	{
		scriptColData.value = "Yes";
	}
	else
	{
		scriptColData.value = "No";
	}
}

Select folders with a folder picture
#5

Wow. That is above and beyond. Will try it out. Thanks @Leo!


#6

Works like a champ! Thanks again. Save me a few hours.


#7

Nice solution @Leo.

This kind of thing comes up every now and then. Would make a good generic script.

For when using a filter could we update it to accept a match string to the script column?

This would make mean the column does not work as a normal column. But would add some value in this scenario.


#8

I don’t think script columns can do that. They aren’t told what the filter is looking for.


#9

Might be a useful addition to support something like this.


#10

For anyone finding this thread, here's a related thread which has some other methods of doing similar things.

The script I posted above is a good solution for some tasks, but the ones in the other thread may suit you better, depending on exactly what you need to do.