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