About 8,140,000 results
Open links in new tab
  1. python - Get a filtered list of files in a directory - Stack Overflow

    Feb 9, 2010 · use os.walk to recursively list your files. import os root = "/home" pattern = "145992" alist_filter = ['jpg','bmp','png','gif'] path=os.path.join(root,"mydir_to_scan") for r,d,f in …

  2. Python – List Files in a Directory - GeeksforGeeks

    Dec 20, 2024 · List Files in a Directory Using the Glob Module in Python . The glob module retrieves files/path names matching a specified pattern. Below are the ways by which we can …

  3. Python Glob: Filename Pattern Matching - PYnative

    Jun 17, 2021 · Python glob.glob() method returns a list of files or folders that matches the path specified in the pathname argument. This function takes two arguments, namely pathname, …

  4. How to get list files matching name in Python - Stack Overflow

    I am trying to get a list of files in a directory which match a certain name e.g in Bash the Code would be : BASH FOLDER="MainProject" FILES=`find "$FOLDER" -name "Localizations*swift"`

  5. How to Get a List of All Files in a Directory With Python

    Jan 12, 2025 · To get all the files in a directory with Python, you can leverage the pathlib module. This tutorial covers how to use methods like .iterdir(), .glob(), and .rglob() to list directory …

  6. Python List All Files In Directory And Subdirectories

    Apr 24, 2025 · In this example, the Python function `list_files_glob` uses the ` glob ` module to list and print the full paths of files matching a specified pattern (`'./**/*'` by default). The `recursive` …

  7. How to List Files in a Directory with Python? - Python Guides

    Feb 14, 2025 · Learn how to list files in a directory using Python with `os.listdir()`, `glob.glob()`, and `os.walk()`. Explore different methods to retrieve filenames. Skip to content

  8. Printing a List of Files in Directory and Subdirectories in Python

    Apr 29, 2025 · P athlib is a modern, object-oriented approach for managing filesystem paths, and we can use its pathlib.Path.rglob() method to traverse the directory and yields Path objects …

  9. Python: List Files in a Directory - Apps Developer Blog

    Mar 22, 2024 · Using os.listdir () function to obtain a list of files: Once you have the directory path, you can use the os.listdir() function to retrieve a list of files present in that directory. This …

  10. How to Match Files in a Directory Using Python? - Medium

    Jan 18, 2024 · For example, we can use the following pattern to match all Python files in the current directory: >>> glob.glob('*.py') ['fileC.py', 'fileD.py'] We can also use absolute paths to …

Refresh