pathlib list files in directory You can use .glob() with a regular expression. Here we also turn it into a generator: def get_notes(notes_dir): yield from notes_dir.glob("*.md") #pathlib #generators