๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ glob.html
glob โ€” Unix style pathname pattern expansion โ€” Python 3.15.2 documentation
Source code: Lib/glob.py The glob module finds pathnames using pattern matching rules similar to the Unix shell. No tilde expansion is done, but*,?, and character ranges expressed with[] will be co...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_module_glob.asp
Python glob Module
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ยท โฎ Standard Library Modules ยท Find files matching a pattern: import glob import tempfile import os with tempfile.TemporaryDirectory() as d: open(os.path.join(d, "Emil.txt"), "w").close() open(os.path.join(d, "Linus.txt"), "w").close() open(os.path.join(d, "Tobias.py"), "w").close() hits = glob.glob(os.path.join(d, "*.txt")) print(sorted(os.path.basename(x) for x in hits)) Try it Yourself ยป ยท
๐ŸŒ
Real Python
realpython.com โ€บ ref โ€บ stdlib โ€บ glob
glob | Python Standard Library โ€“ Real Python
>>> import glob >>> image_files = glob.glob('**/*.jpg', recursive=True) + \ ... glob.glob('**/*.png', recursive=True) + \ ... glob.glob('**/*.gif', recursive=True) ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-use-glob-function-to-find-files-recursively-in-python
How to use Glob() Function to Find Files Recursively in Python - GeeksforGeeks
October 3, 2025 - print("\nUsing glob.iglob()") for filename in glob.iglob('/home/geeks/Desktop/gfg/**/*.txt', recursive = True): print(filename) ... as it is specifically designed and optimized to allow recursive browsing of a directory tree.
๐ŸŒ
Learn By Example
learnbyexample.org โ€บ python-glob-glob-function
Python glob.glob() Function - Learn By Example
April 14, 2024 - Letโ€™s consider a sample directory tree for following examples: sample_directory/ โ”œโ”€โ”€ data.txt โ”œโ”€โ”€ report-1.txt โ”œโ”€โ”€ report-a.txt โ”œโ”€โ”€ report-b.txt โ”œโ”€โ”€ my_photo.jpg โ”œโ”€โ”€ image1.jpg โ”œโ”€โ”€ image2.jpg โ”œโ”€โ”€ folder1/ โ”‚ โ”œโ”€โ”€ a1.txt โ”‚ โ”œโ”€โ”€ b2.pdf โ””โ”€โ”€ folder2/ โ”œโ”€โ”€ c3.txt ยท This pattern matches an exact file or directory in the specified path. import glob # Match data.txt in C:\sample_directory for name in glob.glob(r'C:\sample_directory\data.txt'): print(name) # Output: C:\sample_directory\data.txt
๐ŸŒ
Built In
builtin.com โ€บ software-engineering-perspectives โ€บ glob-in-python
Glob in Python Explained | Built In
Glob is a Python module thatโ€™s used to find all file path names that match a specific pattern. Hereโ€™s how to use it.
๐ŸŒ
TechBeamers
techbeamers.com โ€บ python-glob
Python Glob Module Methods (with Patterns) - TechBeamers
December 30, 2025 - Itโ€™s particularly useful for ... of filenames that match a given pattern. For example, glob.glob(โ€œ*.pyโ€) will return all Python files in the current directory....
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python โ€บ glob module โ€บ .glob()
Python | Glob Module | .glob() | Codecademy
June 25, 2022 - Learn the basics of Python 3.13, one of the most powerful, versatile, and in-demand programming languages today. ... The pathname must be a valid string that represents a file path that can either be absolute or relative. By default, recursive is set to False. But when set to True, the pattern ** can be used to match any files and folders in a given directory. The example below showcases some common use-cases for the .glob...
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ glob() in python
glob() in Python - Scaler Topics
May 4, 2023 - For example, the sample_files folder contained two text files named random_text_1.txt and random_text_2.txt. And files are a variable instantiated(created from the class as an instance) as an object of the glob class and return a list as the output. We will see more about the glob() function ...
Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ django-unleashed โ€บ python-file-handling-with-the-glob-module-a-comprehensive-guide-10b209fcbfbb
Python File Handling with the glob Module: A Comprehensive Guide | by Mehedi Khan | Django Unleashed | Medium
February 15, 2025 - In Python, handling files and directories efficiently is crucial for many tasks, whether youโ€™re working on a small project or a large-scale application. The glob module in Python is a powerful tool that simplifies the process of finding files that match a specific pattern in a directory.
๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ python glob: filename pattern matching
Python Glob: Filename Pattern Matching โ€“ PYnative
June 17, 2021 - Use Python 3.5+ to find files recursively using the glob module. The glob module supports the ** directive. When you set a recursive flag to True, the glob method parses the given path look recursively in the directories. Example to search .txt files under all subdirectories of the current directory.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
How to Use glob() in Python | note.nkmk.me
July 28, 2023 - Use glob() to generate a list of files and directories recursively, then apply re.search() to this list. For example, you can extract files that either have a file name composed solely of numbers with an extension of txt, or files with a file name of 3 characters that are not numbers with an extension of either txt or jpg...
๐ŸŒ
Python Module of the Week
pymotw.com โ€บ 2 โ€บ glob
glob โ€“ Filename pattern matching - Python Module of the Week
If you are looking for examples that work under Python 3, please refer to the PyMOTW-3 section of the site. Now available for Python 3! Buy the book! ... Even though the glob API is very simple, the module packs a lot of power. It is useful in any situation where your program needs to look for a list of files on the filesystem with names matching a pattern.
๐ŸŒ
Python
docs.python.org โ€บ 3.9 โ€บ library โ€บ glob.html
glob โ€” Unix style pathname pattern expansion โ€” Python 3.9.25 documentation
July 8, 2025 - Raises an auditing event glob.glob with arguments pathname, recursive. ... Escape all special characters ('?', '*' and '['). This is useful if you want to match an arbitrary literal string that may have special characters in it. Special characters in drive/UNC sharepoints are not escaped, e.g. on Windows escape('//?/c:/Quo vadis?.txt') returns '//?/c:/Quo vadis[?].txt'. New in version 3.4. For example, consider a directory containing the following files: 1.gif, 2.txt, card.gif and a subdirectory sub which contains only the file 3.txt.
๐ŸŒ
Michael Currin
michaelcurrin.github.io โ€บ dev-cheatsheets โ€บ cheatsheets โ€บ python โ€บ files-and-paths โ€บ glob.html
Glob | Dev Cheatsheets
glob in the Python 3 docs. From this StackOverflow page, where my answer was the highest voted. Provide a path as a single argument. You get results as absolute paths. glob.glob("some_dir/*.png") # => ['/home/michael/foo/bar/some_dir/a.png', '/home/michael/foo/baz/some_dir/b.png', ] In this example, the current working directory was above some_dir, but you could change directory first and then run the glob using the short pattern *.png.
๐ŸŒ
Python
docs.python.org โ€บ 3.8 โ€บ library โ€บ glob.html
glob โ€” Unix style pathname pattern expansion โ€” Python 3.8.20 documentation
September 8, 2024 - Raises an auditing event glob.glob with arguments pathname, recursive. ... Escape all special characters ('?', '*' and '['). This is useful if you want to match an arbitrary literal string that may have special characters in it. Special characters in drive/UNC sharepoints are not escaped, e.g. on Windows escape('//?/c:/Quo vadis?.txt') returns '//?/c:/Quo vadis[?].txt'. New in version 3.4. For example, consider a directory containing the following files: 1.gif, 2.txt, card.gif and a subdirectory sub which contains only the file 3.txt.
๐ŸŒ
Georgefox
cs.georgefox.edu โ€บ hs_contest โ€บ docs โ€บ python-3.10.12-docs โ€บ library โ€บ glob.html
glob โ€” Unix style pathname pattern expansion โ€” Python 3.10.12 documentation
If the directory contains files starting with . they wonโ€™t be matched by default. For example, consider a directory containing card.gif and .card.gif: >>> import glob >>> glob.glob('*.gif') ['card.gif'] >>> glob.glob('.c*') ['.card.gif'] ... ยฉ Copyright 2001-2023, Python Software Foundation.
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ glob-python
Python glob module: How to use glob function? (& glob vs iglob)
February 27, 2023 - To use the glob function, first include the glob module in your Python script. After that, you may use the glob function to find all the files that match a specific pattern. For example, the code below shows how to use the glob function to find all.txt files in a directory: