How to filter items by location or sub-folder


Since this guide was written, the ability to filter by Full Path was added. You can now apply wildcards and regexps to each file's full path in one line. This is sometimes easier than separately testing the filename and the parent folder's path.

Everything below still works, and the fundamentals remain the same, but you might want to consider using Full Path instead of Location in some cases. Of course, which is best depends on exactly what you are doing, and using Location is still better in some cases.

Three ways to filter by location:

This post explains how to use Location and Subfolder clauses to filter items based on their directory path. It's in the form of a question & answer:

Here are three 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. (Easy to forget to do that with extensions.)

  1. The first example is the most simple. The important difference to what you were doing is it matches on *\old, not just old, since the Location is a full path, not just the parent folder's name.

  2. Expanding on that, note that the first example will not exclude things which are in a subdirectory of "old" (unless the subdirectory is also called "old").

    This second example corrects that problem and excludes everything in or below any folder called "old". If you expand the wildcards it is excluding both *\old and *\old\*

  3. Now for the final example. This will match exactly the same things as the previous example, but it is more efficient:

    If you use a Subfolder clause then Opus will not even enter any folders called "old", which will speed things up a lot if there are a lot of things below the folders you want to skip over. On the other hand, if you use a Location clause instead of a Subfolder clause then Opus still goes through each and every file & directory testing its Location against the rules.

    So the third example is the best one but I included the others so you can see how the Location clause works. Both Location and Subfolder are useful in different circumstances.

    Note about Synchronize: Subfolder clauses do not currently work with the Synchronize tool in Opus. If you're using the filter there you should use Location clauses 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.

1 Like
Can I show folders down to a certain level?
Exclude folders when doing a FIND
How to skip certain directory in the filter?
Hiding folders based on name
Using 'Find' in collections
Search - Number of subfolders
Compare two folders
Ignoring a folder when using sync
Exclude Recycle Bin from searches
Excluding directories from a search
"Use Filter" for Recycle isn't working
Need help about synchronization filter
Help on find filter
Simple Find - Exclude Folder & Exclude Extension
Searching filtering to a subfolder depth
Advanced Select Assistance
Advanced Select Assistance
Copy Filter in
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
Search function functionality
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
Cannot use Boolean Functions when Searching
Using Synchronize filters with FTP site
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
Search for, excluding
Filter/omit .git directory when copying
Exclude Directory in a Search
Using copy filter to upload to FTP server
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)