Add Directory/File Exclusion Regex Option #395
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
An implementation idea for part of #149 (ignoring certain files/directories, see this comment).
The idea is to allow for an exclusion regex for file and directory names (separately, for flexibility) in the configuration.
This would allow e.g. for setting the regex for directories to
^\.ignore$and then you could just move all of your ignorable files/directories containing archives there.Since it's a global setting it also works for subdirectories, so e.g. a structure like this:
files ├── Game A │ ├── Game A (v1.0) (2025).zip │ └── .ignore │ ├── other_stuff.zip │ └── patch.zip ├── Game B │ └── ... └── Game C └── ...For the future, this could be combined as an enhancement to file organization with the original idea of #149, where file name constraints for files enhancing the game archive ('Extras') are suggested.
Reasoning
The indexer picking up any and all archives seems a bit too broad. While this automatically excludes e.g. images, videos, text files and the like, it does not exclude any archives. For games, aside from the aforementioned file types, you may additionally store game patches as archives to conserve space (and to have the patch in once place, as it may not be consisting of one file only).
There is currently no clear option to exclude archives from being picked up.
Implementation Details
New (optional) string environment variables:
GAMES_SEARCH_EXCLUDE_DIR_REGEXGAMES_SEARCH_EXCLUDE_FILE_REGEXSince
fs.readdir()does not have an exclusion setting, it became necessary to write a recursive walk function.I don't really know how this will behave for large libraries though, especially since during the walk a lot of Promises could spawn and try to resolve all at once. There is likely a more efficient implementation.
Update (2026-01-03): I see that this commit in the
developbranch reimplements thereadAllFilesmethod usingreaddirp, which actually does support this usecase. Therefore you should be able to simply set thefileFilteranddirectoryFilterarguments to a regex test of the file/dir name withGAMES_SEARCH_EXCLUDE_FILE_REGEXandGAMES_SEARCH_EXCLUDE_DIR_REGEXaccordingly.