How to find a folder that contains an item?

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.

Can anyone tell me how to set this up?

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.)

Thanks Leo, I've been doing it the first way, but I will give the button method a try!

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.

Regards, AB

As Leo reminded me :blush: in an unrelated thread, FIND is a much better way to locate instances of a specific filename. For example:


You can then generate a containing folder list using Tools --> Print/Export Folder Listing...


This simple text list is based on an output format with Filename and Location columns.

Regards, AB

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.)

Yes, that did it. Saving me hours of routing through directories. Thanks again! :thumbsup: