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

Is it possible to select folders which subfolder(s), or the folder itself, contains a certain file?
For example:
I want to select the folders which folder or subfolder(s) contains the file "iso".
D:\Movies
------------\one\five\1111.iso
------------\two\six\seven\2222.iso
------------\three\eight\3333.jpg
------------\four\4444.iso

So I want the following folders selected (one, two and four) because they contain an ".iso" file :
D:\Movies
------------\one
------------\two
------------\four

Is it possible to achieve this through a filter or something else?

A script could be written to do that. I can't think of an easier way.

Maybe you can try, if this is working for you:

@disablenosel 
Find RECURSE NAME=* IN {allfilepath$}
set COLUMNS=path(2) 
set sortby=+path(2) FOCUS=Source HIDEFILTERFOLDERS=* SHOWFILTERFILENAME=*.iso

You can bind that code to a hotkey or button, select the folders in question & should be able to have only the ISOs shown from your selected folders.

I haven't tried your code yet because I don't now what to do with it. I've pasted it into the "command prompt here" window but that didn't work.

But for I try further, is your code only showing the ISO files?
Because I want to select the folder's they're in and not only showing the ISO's.
I have a lot of folders and in each folder or subfolder is an ISO or video-ts folder. I only want to do something with the folder's that contains an ISO. So I want to select these folders.

You need to create a button to execute @abr's command. See...

http://www.gpsoft.com.au/help/opus11/index.html#!Documents/customize.htm

and

http://www.gpsoft.com.au/help/opus11/index.html#!Documents/Editing_the_Toolbar.htm

Regards, AB

You can download the button, which is attached to this post. If you right click an empty space in your toolbar, & select "customize", you can then drag that
button into your toolbar. Click "OK" to save the changes. But please note, that this code isn't exactly doing, what you asked for. Instead of selecting the folders, which
contain the ISOs, it will show the contained ISOs in the folders, you run this button on, which might be also helpful.
Show ISOs in selected.dcf (472 Bytes)

Ok, I've tried it. It's like you said, it shows the contained ISO's and don't select the folders.
I want to select these folders so I can edit them and don't edit the folders that contain a VIDEO_TS folder.
It are too many folders to select these one by one.

I've read this How to filter items by location or sub-folder
If I understand it well is the third filter (named here final example) something to exclude subfolders with a specific name.

Is it possible to exclude folders that have a subfolder with a specific name?
What I mean is the following... I want to select all folders that contain an ISO-file in it's folder or subfolder, and exclude folders that have a subfolder called "video_ts".
Is this something that's possible with a filter?

As the example shows, it is possible. Give it a try.. o)
DO is in no way comparable to the Explorer, but does need exploring from time to time.. o)

I don't think filtering will work for this.

A script is probably needed instead. A script can recursively look through the directories for *.iso files and select them if one is found.

This example is to exclude a subfolder. I want to exclude the folder where the subfolder "video_ts" is placed. I don't know how to do this.

Do you know where, or is here someone on the forum, I can ask for such a script?

We may write scripts for people who have linked their accoubts, but can't guarantee it (this isn't a consultancy service :slight_smile: but if we find time we will help out).

Fellow users may also write scripts if they see a thread here and are interested and feeling generous.

Thank you. At the moment I'm using a trial version to see if Directory Opus can do what I'm trying to achieve. Can I link my account with a trial version of is this only possible with a purchased version?

Only possible with a purchased version, sorry.

You may try this script/button. To do so, select the code below and paste it onto any toolbar while DO is in customize mode.
You can select folders in a lister before using the button. If no folder is selected, all folders will be checked.
If an iso-file but no video_ts-folder was found - the folder will be selected.
You get some detailed output in the log window and a message box at the end telling results (how many folders found).

This is my first experiment in dopus scripting, hopefully it does what you aim for.. o)

@Leo, Wow and Steje
It seems you got me going! Thanks again for answering my noob questions! o)

(Code removed, see next post for an updated version.)

Small update to make it a bit more versatile and clean.
The filetype/extension and subfolder-name to exclude (optional now) is configurable at the top.

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>ISO-FolderSelector</label>
	<tip>ISO-FolderSelector</tip>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script jscript</instruction>
		<instruction>///////////////////////////////////////////////////////////////////////////////</instruction>
		<instruction>// Script to select folders.</instruction>
		<instruction>// They will be selected if they contain files with &lt;extension&gt; and at the same</instruction>
		<instruction>// time do not contain a subfolder named &lt;excludeSubfolder&gt; (optional).</instruction>
		<instruction>///////////////////////////////////////////////////////////////////////////////</instruction>
		<instruction>var extension = &apos;.iso&apos;;</instruction>
		<instruction>var excludeSubfolder = &apos;video_ts&apos;;</instruction>
		<instruction />
		<instruction>function OnClick(data) {</instruction>
		<instruction>	DOpus.ClearOutput();</instruction>
		<instruction>	data.func.command.ClearFiles();</instruction>
		<instruction />
		<instruction>	if (data.func.sourcetab.selected_dirs.count)</instruction>
		<instruction>		var objEnum = new Enumerator( data.func.sourcetab.selected_dirs );</instruction>
		<instruction>	else</instruction>
		<instruction>		var objEnum = new Enumerator( data.func.sourcetab.dirs );</instruction>
		<instruction />
		<instruction>	while (!objEnum.atEnd()) {</instruction>
		<instruction>		var folder = objEnum.item(); objEnum.moveNext();</instruction>
		<instruction>		dout(&quot;Folder [&quot;+folder.name+&quot;]..&quot;);</instruction>
		<instruction>		if (excludeSubfolder!=&apos;&apos; &amp;&amp; SubFolderExists( folder.path+&quot;\\&quot;+folder.name, excludeSubfolder)){</instruction>
		<instruction>			dout(&quot;    Contains folder [&quot;+excludeSubfolder+&quot;], skipping search for *&quot;+extension+&quot;.&quot;);</instruction>
		<instruction>			continue;</instruction>
		<instruction>		}</instruction>
		<instruction>		if (exists = FileExtensionExists( folder.path+&quot;\\&quot;+folder.name, extension)){</instruction>
		<instruction>			dout(&quot;    Contains at least one *&quot;+extension+&quot; file.&quot;);</instruction>
		<instruction>			data.func.command.AddFile(folder);</instruction>
		<instruction>		}</instruction>
		<instruction>    	}</instruction>
		<instruction>	data.func.command.RunCommand(&quot;Select FROMSCRIPT DESELECTNOMATCH MAKEVISIBLE&quot;);</instruction>
		<instruction>	DOMsgBox(&quot;ISO-FolderSelector&quot;,&quot;Found &quot;+data.func.command.files.count+&quot; folder(s) containing *&quot;+extension+&quot; file(s).&quot;,&quot;Ok&quot;);</instruction>
		<instruction>}</instruction>
		<instruction>///////////////////////////////////////////////////////////////////////////////</instruction>
		<instruction>function ReadFolder( path, recurse, exception){</instruction>
		<instruction>	if (recurse == undefined) recurse=false;</instruction>
		<instruction>	if (exception == undefined) exception=true;</instruction>
		<instruction>	var fEnum = DOpus.FSUtil.ReadDir( path, true);</instruction>
		<instruction>	if (fEnum.error!=0){</instruction>
		<instruction>		var error = &quot;ReadFolder(): Error reading folder [&quot;+name+&quot;], code [&quot;+fEnum.error+&quot;].&quot;;</instruction>
		<instruction>		if (exception) throw error;</instruction>
		<instruction>		DOpus.Output(error);</instruction>
		<instruction>	}</instruction>
		<instruction>	return fEnum;</instruction>
		<instruction>}</instruction>
		<instruction>///////////////////////////////////////////////////////////////////////////////</instruction>
		<instruction>function SubFolderExists( folderPath, subFolderName){</instruction>
		<instruction>	subFolderName = subFolderName.toLowerCase();</instruction>
		<instruction>	var fEnum = ReadFolder( folderPath, true, true);</instruction>
		<instruction>	while (!fEnum.complete &amp;&amp; (fItem = fEnum.Next()))</instruction>
		<instruction>		if (fItem.is_dir &amp;&amp; (fItem.name.toLowerCase() == subFolderName))</instruction>
		<instruction>			return true;</instruction>
		<instruction>	return false;</instruction>
		<instruction>}</instruction>
		<instruction>///////////////////////////////////////////////////////////////////////////////</instruction>
		<instruction>function FileExtensionExists( folderPath, extension){</instruction>
		<instruction>	extension = extension.toLowerCase();</instruction>
		<instruction>	var fEnum = ReadFolder( folderPath, true, true);</instruction>
		<instruction>	while (!fEnum.complete &amp;&amp; (fItem = fEnum.Next()))</instruction>
		<instruction>		if (!fItem.is_dir &amp;&amp; (fItem.ext.toLowerCase() == extension))</instruction>
		<instruction>			return true;</instruction>
		<instruction>	return false;</instruction>
		<instruction>}</instruction>
		<instruction>///////////////////////////////////////////////////////////////////////////////</instruction>
		<instruction>function DOMsgBox(title,message,buttons){</instruction>
		<instruction>	var dlg = DOpus.Dlg</instruction>
		<instruction>	dlg.window = DOpus.Listers(0);</instruction>
		<instruction>	dlg.message = message;</instruction>
		<instruction>	dlg.title = title;</instruction>
		<instruction>	dlg.buttons = buttons;</instruction>
		<instruction>	var result = dlg.Show();</instruction>
		<instruction>	dout(title+&quot; - &quot;+message+&quot; - &quot;+buttons+&quot; -&gt; &quot;+result);</instruction>
		<instruction>	return result;</instruction>
		<instruction>}</instruction>
		<instruction>///////////////////////////////////////////////////////////////////////////////</instruction>
		<instruction>function dout(text){</instruction>
		<instruction>	DOpus.Output(text);</instruction>
		<instruction>}</instruction>
	</function>
</button>

Thank you, and again thank you very much for your time and help to write this.

You say that the filetype/extension and subfolder-name to exclude (optional now) is configurable at the top.
The subfolder-name seems not an optional choice at the moment because now it takes into consideration the video_ts folder.
What do I have to change or write instead of "video_ts" to make it optional like you said? Or have I misunderstood you?

Ok, so basically it works for you? To select folders, which contain the given extension, regardless of any subfolder, just edit this line:
var excludeSubfolder = 'video_ts';
into
var excludeSubfolder = '';

Note: These ->'' are two single quotes ->'.
You may use two double quotes as well for strings in jscript: var excludeSubfolder = ""; which are much easier for the eye.

Clearing the content of the variable may not be the most elegant way of changing how the script works, but get's the job done.
I hope the button serves well for what Leo had initially promised.. o)

I've tested it on 3 folders. That seems to work. Now I'm going to test it on all my folders.

I'm having no line:
var excludeSubfolder = 'video_ts';

Only have this line:
var excludeSubfolder = 'video_ts'

Is that the line you intended?