Ability to create collection of all folders that contain a specific file type

Is there a way to do an advanced find to search a directory recursively that will return the folders only, of any folder that has a specific file type in it?

So if I search for .txt files, I would like a list of folders that include .txt files directly in that folder.

I did find this thread, which is similar, but I am dealing with thousands of files, so I would like it to be as smart as possible. I might scan a directory and find 200,000 files of that type in 10 folders, or in other projects, I might have 20,000 folders with 100 files in each. So I am trying to find a way to list the folders once, and not have to use external applications to filter the list down.


The way to do it is via a script column which indicates if a folder has the type of file you're interested in, and then filter on that column.

There's a script already written here where you'd just need to edit the wildcard at the top:

Instructions on how to use the script are in this earlier post in the same thread (which has a slightly different script for finding something else):

Thank you Leo. This works exactly as I had hoped, and is very easy to edit for different file types.

One more thing that might help me with the next step of what I am trying to do.

Is it possible to now delete the found set, with exceptions. For Example if the found folders contain .txt files and .doc files, I would like to delete only the .txt files. The reason I am filtering down like this, instead of just searching for .txt files is mainly because we are dealing with such large quantities of files, it is cumbersome to look through the list of files found to make sure we did not catch an unintended folder when the find window has thousands of files to look through. But when there are a dozen or two folders, it is easier to make sure we have narrowed the criteria down accurately.

I I thought 'refine previous search' would do it, but I can't seem to get that to work. I guess what I am trying to do is to then do a file search against only the folders that were found in the previous step?

I am sure there is a simpler way of doing and explaining this, but when ever deleting files, we want to be as careful as possible, right? :slight_smile:

You could:

  • Drag & drop all the found folders on to the Find panel's Find In list, so they are where it will search below.

  • Set the find panel to not search in sub-folders.

  • Find *.txt

That would give you a list of all .txt files within the folders you have found previously.

Alternatively, you could modify the script from before so that it returns a list of .txt files that are also in folders with .doc files. That would get you the list of .txt files directly.

Nice! Thanks.. I didn't realize you could drag into the Find In List.... I was always using the + to add paths.