FoxTrot Search Forum
FoxTrot Search for macOS Forum

Home » Public Forums » FoxTrot Search User Forum » Exclude subfolders from index by folder name (filter index)
Exclude subfolders from index by folder name [message #1683] Sun, 13 August 2023 15:05 Go to next message
es
Messages: 9
Registered: July 2023
Junior Member
If I include some folder as a separate index, I see the option to skip specific individual subfolders.

But I'd like to exclude all subfolders matching some glob/regex, e.g., exclude all subfolders named "cache"

Is it possible?
Thank you
Re: Exclude subfolders from index by folder name [message #1686 is a reply to message #1683] Wed, 23 August 2023 11:15 Go to previous messageGo to next message
FoxTrot Engineering
Messages: 384
Registered: April 2020
Senior Member
No, you can't exclude folders using some glob/regex at indexing time.
You can however ignore found files with a regular expression when performing a search:
[then apply advanced filter] [full path] [does not contain the regular expression]


Jérôme - FoxTrot Engineering
Re: Exclude subfolders from index by folder name [message #1687 is a reply to message #1686] Wed, 23 August 2023 15:35 Go to previous messageGo to next message
es
Messages: 9
Registered: July 2023
Junior Member
Filtering out on every search is rather inconvenient; besides such folders occupy unnecessary space in the index. Could this be added in the earlier phase?
Re: Exclude subfolders from index by folder name [message #1688 is a reply to message #1687] Wed, 23 August 2023 16:48 Go to previous messageGo to next message
FoxTrot Engineering
Messages: 384
Registered: April 2020
Senior Member
Another option is to add an empty file named ".noindex" in each of the folders yo want to skip at indexing time. As the Finder hides files whose name begin with a dot, you need to show invisible files (command-shift-.) in order to create (or rename or delete) such a file from the Finder.

Jérôme - FoxTrot Engineering
Re: Exclude subfolders from index by folder name [message #1689 is a reply to message #1688] Wed, 23 August 2023 19:36 Go to previous messageGo to next message
es
Messages: 9
Registered: July 2023
Junior Member
Thanks for the tip, but unfortunately many of such folders are dynamic, created by other tools, so chasing them with manual noindex files is also not pretty; then some could be inside version controlled folders, so you'd need to exclude .noindex files from being visible, another complication...
Re: Exclude subfolders from index by folder name [message #1690 is a reply to message #1689] Thu, 24 August 2023 09:13 Go to previous messageGo to next message
FoxTrot Engineering
Messages: 384
Registered: April 2020
Senior Member
We will consider adding a hidden preference (accessible via Terminal.app) for this in the future. This will probably be a global (i.e. not per-index) setting, with a regular expression.

For example, if you want to skip all folders named "cache" or "meta", the command line to set this hidden preference would be something like:
defaults write com.ctmdev.FoxTrotShared SkipFoldersRegex '/(cache|meta)$'
Or if you want to skip these folders only when located at any depth inside another folder whose name ends with ".repo", the command line would be:
defaults write com.ctmdev.FoxTrotShared SkipFoldersRegex '\.repo/(.*/)?(cache|meta)$'
Would this work for you?


Jérôme - FoxTrot Engineering
Re: Exclude subfolders from index by folder name [message #1691 is a reply to message #1690] Thu, 24 August 2023 11:12 Go to previous messageGo to next message
es
Messages: 9
Registered: July 2023
Junior Member
Hidden terminal preference is a poor UI. Now whenever I find some garbage in the search results that I can generalize to some exclude rule instead of adding a new filter to the Blacklist I'd have to remember the cli incantation and also remember the old regex to add to it, and that regex will get rather unwieldy

And it's also not just a folder regex, but also files

And it should be per index since the exclusion rules aren't global by nature, e.g., I'd like to exclude various build artifacts everywhere except for my Source Code regex, where it's fine to have them included as they might contain useful information

Thank you
Re: Exclude subfolders from index by folder name [message #1692 is a reply to message #1691] Fri, 25 August 2023 18:05 Go to previous messageGo to next message
FoxTrot Engineering
Messages: 384
Registered: April 2020
Senior Member
This hidden preference will be implemented in FoxTrot Pro version 8 (the beta version will be announced soon). We won't surcharge the user interface with this.

You can use Prefs Editor to change these hidden preferences without using Terminal.app.

This setting will apply both for folders and files, and you can add multiple regular expressions if you have different patterns to skip.

The setting is ignored for folders that you directly add to the indexed locations; i.e. if you skip all folders named "cache", but explicitly add a specific "cache" folder to the indexed location, this one will be indexed.

A few examples:
To skip any folder whose name is exactly "cache" or "meta" (case sensitive), use one of these commands:
defaults write com.ctmdev.FoxTrotShared SkipPathRegex -string '/(cache|meta)$'
defaults write com.ctmdev.FoxTrotShared SkipPathRegex -array -string '/cache$' -string '/meta$'
To do the same only at any depth inside a folder whose name ends with ".repo", use one of these commands:
defaults write com.ctmdev.FoxTrotShared SkipPathRegex -string '\.repo/(.*/)?(cache|meta)$'
defaults write com.ctmdev.FoxTrotShared SkipPathRegex -array -string '\.repo/(.*/)?cache$' -string '\.repo/(.*/)?meta$'


Jérôme - FoxTrot Engineering
Re: Exclude subfolders from index by folder name [message #1693 is a reply to message #1692] Sat, 26 August 2023 08:04 Go to previous messageGo to next message
es
Messages: 9
Registered: July 2023
Junior Member
FoxTrot Engineering wrote on Fri, 25 August 2023 18:05
This setting will apply both for folders and files
But these are very different, can you add a flag to separate those two? I mean, if you're doing it in such an inconvenient registry/terminal way, at least would be nice if it were powerful!

Also, what regex engine are you using so I could test the rules before adding them?

Thanks
Re: Exclude subfolders from index by folder name [message #1694 is a reply to message #1693] Sat, 26 August 2023 10:52 Go to previous messageGo to next message
FoxTrot Engineering
Messages: 384
Registered: April 2020
Senior Member
Could you give some use cases where using a pattern to skip some files is necessary, but would also match some folders that should not be skipped (or vice versa)? You can easily write a regex that only targets folders, or more accurately, the contents of these folders (like /cache/ ); however targeting files but not folders having the same name is probably not possible.

We are using PCRE2 for our regular expression engine.


Jérôme - FoxTrot Engineering
Re: Exclude subfolders from index by folder name [message #1695 is a reply to message #1694] Sat, 26 August 2023 13:59 Go to previous messageGo to next message
es
Messages: 9
Registered: July 2023
Junior Member
One example would be to differentiate between autogenerated folders like "build" but preserve manually created quick scratch files (thus without extension). But then if /build/ is enough to exclude the folder it should be fine

Not sure about a good opposite example, just didn't want to worry that I'd exclude something useful (maybe a test that the last symbol is NOT / would also be enough?)
Re: Exclude subfolders from index by folder name [message #1696 is a reply to message #1695] Sat, 26 August 2023 14:44 Go to previous message
FoxTrot Engineering
Messages: 384
Registered: April 2020
Senior Member
Since FoxTrot does not index the contents of files without a filename extension (unless they have an HFS file type/creator, but that is pretty rare these days…), this should not really be a problem.

Jérôme - FoxTrot Engineering
Previous Topic: New Index of folders/files
Next Topic: Just a little note of thanks
Goto Forum:
  


Current Time: Mon May 06 18:02:31 GMT+2 2024