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\*, :check_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
Exclude folders when doing a FIND
Can I show folders down to a certain level?
How to skip certain directory in the filter?
Hiding folders based on name
Using 'Find' in collections
Compare two folders
Using copy filter to upload to FTP server
Search function functionality
Exclude Recycle Bin from searches
Ignoring a folder when using sync
Help on find filter
Search - Number of subfolders
Filter built in Version 12 no longer works in version 13
Simple Find - Exclude Folder & Exclude Extension
Searching filtering to a subfolder depth
Advanced Select Assistance
Advanced Select Assistance
Copy Filter in 10.0.2.1
Filter (Subfolder) within another filter, unexptected result
Filter look for folders containing *Hit Parade*
Flat View - viewing one level deep only
Control find folder depth
Can I modify the Confirm File replace dialog box?
Exclude filter when copying
Slideshow on search result?
Synchronization filter doesn't work as expected
Print / Export Folder Listing: scan levels
DOpus v10 Suggestion List
Exclude a subdirectory on copy
Search the same folders in Find Panel
Synchronize and skip huge folder
Using Synchronize filters with FTP site
COPY FILTER help
Copying files under specific folders?
List of FAQs organised by topic
Ignore Specific Subfolders / Folders in Search/Find
Synchronize selection
Synchronize selection
Synchronising - how to exclude subfolders + commandlines
Synchronize - remember previous "Source" and "Destination"
Prevent looping symlinks/junctions/hard links in search
Synchronize Folder by Label
Speed up search using filters
Control file display to a directory level in search results
Search for, excluding
Filter/omit .git directory when copying
Exclude Directory in a Search
Print Flatview -- Folder Depth
Filter what is displayed on a tab
Filter what is displayed on a tab
Move all files from sub folder #3 to subfolder #1
Grouped Flat View DEPTH limit switch
How to filter out searching inside directories that match a pattern? impossible?
Filter built in Version 12 no longer works in version 13
Special delete function, filter or special command
Find Tool Exclude Subfolders
How to copy a folder excluding some specific content
Flat View - Only folders, preferably upto one level deep
Filter for Sync
Using Filter when synchronizing
Select folders which (sub)folder(s) contains certain file?
Finding files in a group of folders
Exclude folder from search
Print/Export folder listing for selected files
Filter for visible files/folders only (Sync Panel)
Excluding directories from a search
"Use Filter" for Recycle isn't working
Need help about synchronization filter
Cannot use Boolean Functions when Searching