GP SoftwareTwitter
Opus FAQsManualCommandsObjects

How to filter items by location or sub-folder


#1

Update/Note:

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.


Can I show folders down to a certain level?
Using Filter when synchronizing
How to skip certain directory in the filter?
Searching filtering to a subfolder depth
Search - Number of subfolders
Hiding folders based on name
"Use Filter" for Recycle isn't working
Compare two folders
DOpus v10 Suggestion List
Synchronization filter doesn't work as expected
Exclude filter when copying
Can I modify the Confirm File replace dialog box?
Flat View - viewing one level deep only
Filter look for folders containing *Hit Parade*
Filter (Subfolder) within another filter, unexptected result
Exclude folders when doing a FIND
Copy Filter in 10.0.2.1
Advanced Select Assistance
Advanced Select Assistance
Help on find filter
Need help about synchronization filter
Excluding directories from a search
Filter for visible files/folders only (Sync Panel)
Print/Export folder listing for selected files
Finding files in a group of folders
Select folders which (sub)folder(s) contains certain file?
Slideshow on search result?
Synchronising - how to exclude subfolders + commandlines
Copying files under specific folders?
COPY FILTER help
Using Synchronize filters with FTP site
Exclude Recycle Bin from searches
Exclude a subdirectory on copy
Print / Export Folder Listing: scan levels
Ignoring a folder when using sync
Control find folder depth
Using copy filter to upload to FTP server
Synchronize selection
Synchronize selection
Using 'Find' in collections
Ignore Specific Subfolders / Folders in Search/Find
Synchronize - remember previous "Source" and "Destination"
List of FAQs organised by topic