Top "Pathlib" questions

pathlib offers classes representing filesystem paths with semantics appropriate for different operating systems.

How to get absolute path of a pathlib.Path object?

Making a path object with pathlib module like: p = pathlib.Path('file.txt') The p object will point to some …

python python-3.x pathlib
Listing of all files in directory?

Can anybody help me create a function which will create a list of all files under a certain directory by …

python pathlib
create new folder in python with pathlib and write files into it

I'm doing something like this: import pathlib p = pathlib.Path("temp/").mkdir(parents=True, exist_ok=True) with p.open("…

python-3.x pathlib
From stat().st_mtime to datetime?

What is the most idiomatic/efficient way to convert from a modification time retrieved from stat() call to a datetime …

python python-3.x datetime stat pathlib
Copy file with pathlib in Python

I try to copy a file with pathlib import pathlib import shutil my_file=pathlib.Path('/etc/hosts') to_…

python file copy python-2.x pathlib
How to get folder name, in which given file resides, from pathlib.path?

Is there something similar to os.path.dirname(path), but in pathlib?

python filenames pathlib
Python pathlib make directories if they don’t exist

If I wanted to specify a path to save files to and make directories that don’t exist in that …

python pathlib
Python Pathlib path object not converting to string

I am trying to use Shutil to copy a pdf file using path objects from Pathlib, however when I run …

python shutil pathlib
Recursively iterate through all subdirectories using pathlib

How can I use pathlib to recursively iterate over all subdirectories of a given directory? p = Path('docs') for child …

python python-3.x pathlib
PathLib recursively remove directory?

Is there any way to remove a directory and it’s contents in the PathLib module? With path.unlink() it …

python directory pathlib