Filter for Folders with Specific Content

Hi,

I'm looking for a way to show all the contents of a folder, if that folder contains a matching file. So for example, if a folder contains a file that contains the text "#TEXT", I would like Dopus to then show all the contents of that folder.

My end goal would be: if I search for a particular term in a flat view, I would like Dopus to show me all files that live in the same folders as all matching files (in addition to the matching files themselves), grouped together by folder. Is this possible?

Bump

Not completely, I am afraid. But I can offer a partial solution.

Let's assume you found the files that contain a certain text. You could then use this script to get to a collection of their containers. This allows for a bit browsing, albeit not as comfortably as directly in the folder tree.

With a modified version of the script above you could feed the containers to a Show Filter for a bit more automation. Try and see if Filtering, Flat Viewing and Grouping work together in a useful way.

I'm not sure I understand the question, but a script column could let you filter files based on whether or not another named file exists in the same folder as them. That would let you get a list of all files in folders with the special file.

I think the part I'm not sure about is how you want to display that list.

When I do things like this, I'd usually want to open each folder in a new tab, but you could have all the files in one list, sorted by location to see everything in a single tab.

(If you want to open the folders as tabs, that can be done without any scripts.)

Yes, it is possible. I just have two commands I've writen a few days ago. One is to return a filecollection of parent folders. Another can unpack folders to filecollection which I have posted. I think it will meet your needs if you use together.

Thank you everyone.

Some quick responses to the questions:

@Leo, I should have specified the display I was looking for. For my use case in the ideal scenario, I would like a flat thumbnail display of all these files. What would be the best way to define the script column you mention?

@Yunfei, sorry if I missed it, but where could I find the two scripts you mention?

@lxp, I will try out your script, thank you.

It looks like this script is destructive to the original file structure (i.e., either deletes files in the as provided implementation, or physically moves files in the alternative implementation). Is there a way to create collections without actually moving files on disk?

@lxp, sorry, to add to the above comment, it looks like I misunderstood the first option in the script -- it doesn't appear to actually change the structure on disk; only move does. I'm able to create the collection fine now. How do you link in a collection container into the show filters field?

These are what I've posted. You can have a try now using Unpack MODE=view when unpack. Hope to help you and wait for your feedback.

Thank you! Could you explain a bit more about the "unpack" function? From what I understand, this is meant to be used on a file collection -- does the unpacking take the files from these collections and place them somewhere else? Are any changes made to the actual files on disk?

Here's a quick script. It sets a show filter for folders based on the file collection generated by the other script.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var fsu = DOpus.FSUtil();

    var parentFolders = 'coll://Parentfolders';

    var filterTerm = '';

    var folderEnum = fsu.ReadDir(parentFolders);
    while (!folderEnum.complete) {
        var item = folderEnum.Next();
        filterTerm += item.name + '|';
    }

    filterTerm = 'regex:(' + filterTerm.slice(0, -1) + ')';
    DOpus.Output(filterTerm);
    cmd.RunCommand('Set SHOWFILTERFOLDERS="' + filterTerm + '"');
}

CollectionToShowfilter.dcf (1.4 KB)

Ok, so I think this almost works. The above script creates the show filter perfectly. My end goal though is to view all the files within these specified folders in a flat view. This means I generally select the mixed flat view (no folders) -- the showfiltersfolder works to hide non-matching folders in the mixed folders+files view, but in the flat files only view, the filter doesn't seem to apply (since I'm guessing there are no shown folders to filter out in the first place).

Is there a way to translate the above to the flat files only view?

Adding to this -- if there was a way to specify the full path name on the file name show filter, this would solve the issue too. I could modify your script to simply direct the output to the file show filter instead of the folder show filter, and if it could search for those terms anywhere on the full file path, the problem would be solved. Not sure if filtering on the full path name in show filter is possible though.

I've thought up another way which may be more suitable for you. You can just include the folders in coll://Parentfolders to windows library and then enjoy it.

Doing this requires the files to be physically moved though (if I'm doing the add correctly), which is something I need to avoid doing.

One update here. So I discovered that flatview_folder_filters is false by default; setting this to true eliminates the flat view issue I was having.

However, using your script seems to only search at the top level of the directory initially and only progresses downwards if there is a match. For example, if this is the list of folders in the collection being sent to the filter:

(NEW1|NEW2|NEW3|NEW4)

And if this is the file structure:

NEW

  • NEW1
  • NEW4

NEW2

  • NEW2
  • NEW4

NEW5

  • NEW3

Only the folders NEW2 and NEW2/NEW2 would be shown in the filter. Ideally, I would want the subfolders NEW1, NEW2, NEW3, and NEW4 (from the collection) all to be shown by the filter. But since they are one level deep without parent folders that match terms in the collection, they don't get added to the show filter it appears.

Ok, I've discovered a work around which may satisfy my issue. If you run a find with no search term (* wild card) on a collection, Dopus then lets you access a flat file view for that collection, where you couldn't access the flat view when looking at the collection itself. Using your parent folder scripts, @yunfei and @lxp, I can create the collection I want, and then simply save a find on those collections. It's a bit hacky, but it does pretty much create the exact behavior I want.

Thank you to everyone for all your help. I really do appreciae it.

No. Neither does the windows library nor my commands I replied move files or make changes to the actual disk.