About 55 results
Open links in new tab
  1. python - How to use glob () to find files recursively? - Stack Overflow

    79 Starting with Python 3.4, one can use the glob() method of one of the Path classes in the new pathlib module, which supports ** wildcards. For example:

  2. python - How do I remove/delete/replace a folder that is not empty ...

    It's not fully Python, but it gets it done. The reason I included the pathlib.Path example is because in my experience it's very useful when dealing with many paths that change. The extra steps of importing …

  3. pathlib.Path vs. os.path.join in Python - Stack Overflow

    Apr 15, 2021 · 111 pathlib is the more modern way since Python 3.4. The documentation for pathlib says that "For low-level path manipulation on strings, you can also use the os.path module." It …

  4. python - How to get absolute path of a pathlib.Path object? - Stack ...

    Feb 28, 2017 · p = pathlib.Path('file.txt') The p object will point to some file in the filesystem, since I can do for example p.read_text(). How can I get the absolute path of the p object in a string? Appears …

  5. python - Create new folder with pathlib and write files into it - Stack ...

    In the case of this p = pathlib.Path("temp/") it has created a path p so calling p.open("temp."+fn, "w", encoding ="utf-8") with positional arguments (not using keywords) expects the first to be mode, then …

  6. python - Get directories only with glob pattern using pathlib - Stack ...

    Sep 9, 2022 · 6 I want to use pathlib.glob() to find directories with a specific name pattern (*data) in the current working dir. I don't want to explicitly check via .isdir() or something else. Input data This is the …

  7. python - Use pathlib for S3 paths - Stack Overflow

    Explains how to use Python's pathlib library for handling S3 paths effectively.

  8. How do I check if a directory exists in Python? - Stack Overflow

    133 Python 3.4 introduced the pathlib module into the standard library, which provides an object oriented approach to handle filesystem paths. The is_dir() and exists() methods of a Path object can be used …

  9. How can I replace (or strip) an extension from a filename in Python?

    Longer Answer: The best way to do this will depend on your version of python and how many extensions you need to handle. That said, I'm surprised nobody has mentioned pathlib's with_name. I'm also …

  10. python - pathlib.Path ().glob () and multiple file extension - Stack ...

    Dec 5, 2017 · A bit late to the party with a couple of single-line suggestions that don't require writing a custom function nor the use of a loop and work on Linux: pathlib.Path.glob () takes interleaved …