The pattern rules for glob are not regular expressions. Instead, they follow standard Unix path expansion rules. There are only a few special characters: two different wild-cards, and character ranges are supported [from pymotw: glob – Filename pattern matching].

So you can exclude some files with patterns.
For example to exclude manifests files (files starting with _) with glob, you can use:

files = glob.glob('files_path/[!_]*')
Answer from Kenly on Stack Overflow
🌐
Note.nkmk.me
note.nkmk.me β€Ί home β€Ί python
How to Use glob() in Python | note.nkmk.me
July 28, 2023 - fnmatch β€” Unix filename pattern matching β€” Python 3.11.4 documentation Β· * matches any string, regardless of its length, including zero characters. print(glob.glob('temp/*')) # ['temp/[x].txt', 'temp/12.jpg', 'temp/aaa.jpg', 'temp/dir', 'temp/1.txt', 'temp/123.txt'] print(glob.glob('temp/*.jpg')) # ['temp/12.jpg', 'temp/aaa.jpg'] print(glob.glob('temp/dir/*/*.jpg')) # ['temp/dir/sub_dir1/ccc.jpg', 'temp/dir/sub_dir2/ddd.jpg'] ... For example, to extract paths with file names (excluding extensions) of three characters, use ???.*.
🌐
DNMTechs
dnmtechs.com β€Ί glob-exclude-pattern-in-python-3-programming-a-guide-to-using-exclude-patterns-in-the-glob-module
Glob Exclude Pattern in Python 3 Programming: A Guide to Using Exclude Patterns in the Glob Module – DNMTechs – Sharing and Storing Technology Knowledge
However, sometimes you may want to exclude certain files or directories from your search. This is where the glob exclude pattern comes in handy. A glob exclude pattern is a way to specify files or directories that you want to exclude from a glob search. It is a string pattern that matches files ...
🌐
YouTube
youtube.com β€Ί watch
PYTHON : glob exclude pattern - YouTube
PYTHON : glob exclude pattern [ Gift : Animated Search Engine : https://www.hows.tech/p/recommended.html ] PYTHON : glob exclude pattern Note: The informati
Published: December 5, 2021
🌐
Feldroy
daniel.feldroy.com β€Ί posts β€Ί til-2023-09-ignoring-with-glob
TIL: Finding and ignoring files with Glob
Glob is a really handy tool for finding filepaths. It resembles regular expressions but the syntax is different. Finding matches is easy: # finds python files in the current working directory *.py # finds all the nested python files. **/*.py Β· What I didn't know until today is how to exclude files.
🌐
Python
docs.python.org β€Ί 3 β€Ί library β€Ί glob.html
glob β€” Unix style pathname pattern expansion β€” Python 3.15.2 documentation
Changed in version 3.5: Support for recursive globs using β€œ**”. Changed in version 3.10: Added the root_dir and dir_fd parameters. Changed in version 3.11: Added the include_hidden parameter. ... Escape all special characters ('?', '*' and '['). This is useful if you want to match an arbitrary literal string that may have special characters in it.
🌐
GitHub
facelessuser.github.io β€Ί wcmatch β€Ί glob
wcmatch.glob - Wildcard Match Documentation
RAWCHARS causes string character syntax to be parsed in raw strings: r'\u0040' β†’ r'@'. This will handle standard string escapes and Unicode including r'\N{CHAR NAME}'. NEGATE causes patterns that start with ! to be treated as exclusion patterns. A pattern of !*.py exclude any Python files.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com β€Ί questions β€Ί 59092497 β€Ί python-glob-exclude-pattern-in-the-file-name
python glob exclude pattern in the file name - Stack Overflow
@IlkayIsik I read the comments in the link that you mentioned and most of them say that glob filter are mostly made for simple inclusion and not exclusion.
🌐
Buck
buck.build β€Ί function β€Ί glob.html
glob() - Buck
You cannot specify both the exclude parameter and the excludes parameter because they serve the same purpose.
🌐
Python Fix Issues
fixpython.com β€Ί home β€Ί 2022 β€Ί november β€Ί fix python - glob exclude pattern
Fix Python – glob exclude pattern - Python Fix Issues
November 4, 2022 - For example to exclude manifests files (files starting with _) with glob, you can use: files = glob.glob('files_path/[!_]*') This question is answered By – Kenly Β· This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 Β· Fix Python – String formatting in Python 3 Β·
🌐
YouTube
youtube.com β€Ί the python oracle
glob exclude pattern - YouTube
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn--Music by Eric Matyashttps://www.soundimage.orgTrack title: City Ben...
Published: March 26, 2023
Views: 55
🌐
sqlpey
sqlpey.com β€Ί python β€Ί solved-effective-methods-to-exclude-specific-files-with-glob-patterns-in-python
Solved: Effective Methods to Exclude Specific Files with Glob Patterns in Python
November 6, 2024 - import glob ## Deducting the excluded files from the list of all files excluded_files = set(glob.glob("eph*")) all_files = set(glob.glob("*")) filtered_files = list(all_files - excluded_files) print(filtered_files) The glob function does not support exclusion patterns directly, which invites us to use filtering: import os import glob ## Using list comprehension to filter excluded files files = [fn for fn in glob.glob('somepath/*.txt') if not os.path.basename(fn).startswith('eph')] print(files)
🌐
Baeldung
baeldung.com β€Ί home β€Ί scripting β€Ί how to exclude a pattern from glob match in shell
How to Exclude a Pattern From Glob Match in Shell | Baeldung on Linux
March 18, 2024 - Globbing is based on the use of special characters called wildcards. Wildcards can represent one or more characters in a file name or a string:
🌐
DeepSource
deepsource.com β€Ί blog β€Ί glob-file-patterns
Tips for writing glob patterns in DeepSource configuration β€’ DeepSource
In addition to matching filenames, globs are also used for matching arbitrary strings (wildcard matching) like? which matches a single character. But since, we are focussing on writing test-file and exclude-file patterns we will be focussing on wildcards such as *, ** and / that are widely used for writing glob patterns for matching files in a project.