This may sound like a weird search but I am trying to find a list of folders that contain a specific text file. My backup software didn't "clean up" properly and I've got gigs and gigs of orphaned folders scattered around.
In my mind the search should look like this:
Find Folder
subclause [u]Match [/u]history.txt
+ contains [u]Match [/u]"old file"
But that doesn't work. Basically, the results I want are a list of specific backup folders which contain a certain text file. Once I've found them I can delete them to clear space.
You can't match folders based on the contents of files below them*, but you can get the list of files and then open all the containing folders in new tabs (just select the results and right-click them, the option should be in the menu). From there you can go up a level in each tab and delete the folder.
Or, if there are a huge number of folders, you could create a button which, given a file, deletes its parent folder: Delete {filepath|..} should do it.
(*2019 edit: You can, but it currently needs scripting, so it's not as simple as the other suggestions in most cases.)
Perform a search for duplicates (Ctrl-U). Specify the relevant top level folder in the Find in: panel and add one instance of history.txt in the Search for: panel. When done, use Tools --> Print/Export Folder Listing... to create a text file with a list of Locations (folders containing your search criterion). You may need to edit the Print Folder Contents dialog Format specification to include the Locations column in the output.
I don't think there was a problem with the basic first step of getting the files. The question was how to either turn that into a list of folders or how to delete the folders containing those files. (My answer above should solve it via the second option.)