How to filter items by location or sub-folder

Filtering by location

This is about using filters within things like Tools > Find Files when you want to exclude things under certain directories.

It explains how to use Full Path, Location and Sub-folder clauses to filter items based on their paths.

Below are four slightly different ways to do it.

In all of them, the filename regexp was changed from [0-9]+.png to [0-9]+\.png since, in regexps, . means "match anything" and you have to escape it to \. to match only a literal dot.

Four methods

You only need to use one of these.

  1. Using Full Path is generally the most straightforward. This lets filter files by their full path, including the filename and its parent directories.

    Full Path, No Match, *\old\*, :ballot_box_with_check: Use wildcards will exclude any files whose full path has \old\ somewhere in it. So anything under an old directory will be excluded.

  2. Alternatively, if we use Location instead, this tests against each file's parent directory, with the filename itself removed.

    We test against *\old, not just old, since the Location is a full path of the parent, not just the name of the parent.

    However, note that this (unlike the other examples) will only exclude files directly below a folder named old. Files in a sub-folder under old will still be included! Such files have locations which do not match *\old, since their paths have more after the old.

  3. Expanding on previous example, we can make Location also detect things in sub-directories of old by changing the wildcard to *\old(|\*).

    That's a shorter way of specifying that you want to exclude both *\old and *\old\*. Hopefully you can see now that the first example using Full Path is much easier than this, since you don't have to worry about both cases.

  4. Now for the final example. This will match exactly the same things as examples 1 and 3, but it is more efficient (unless you are using Synchronize; see below).

    If you use a Sub-folder clause like this, Opus will not even enter any folders called old, which will speed things up if those folders have a lot of items below them that all need to be skipped.

    On the other hand, if you use a Full Path or Location clause instead, then Opus still goes through each and every file & directory testing its path or location against the rules.

    So the last example is the best one, but I included the others so you can see how the Full Path and Location clauses work. All are useful in different circumstances.

Note about Synchronize:

Sub-folder clauses do not currently work with the Synchronize tool in Opus. If you're using the filter there, you should use Full Path or Location instead.


Bonus topic: Restricting the search depth

People sometimes want to limit the search depth so that deeply nested folders are ignored. Building on what we used above, Opus can be told not to look inside sub-folders whose locations have too many \ characters in them.


The Location clause tests the full path to the parent of an item.

The folder five with full path C:\one\two\three\four\five has a location of C:\one\two\three\four, which matches *\*\*\*. This means the five folder (and any below it) will not be entered when searching.

Remember that Location is always an absolute path. If you want to limit the depth relative to where your search starts from then you'll have to adjust the wildcard string.

Alternatively, you can use this Script Column which reports path depth as a number which you can filter on:

1 Like