INNER CODE UNIT · Python

get_relpaths_from_dir

mfarragher/obsidiantools · obsidiantools/_io.py:6

def get_relpaths_from_dir(dir_path: Path, *, extension: str) -> list[Path]:
    """Get list of relative paths for {extension} files in a given directory,
    including any subdirectories.

    Thus if the vault directory is the argument, then the function returns
    a list of all the {extension} files found in the vault.

    Args:
        dir_path (pathlib Path): Path object representing the directory
            to search.
        extension (str): file extension like 'md' or 'canvas'.

    Returns:
        list of Path objects
    """
    relpaths_list = [Path(p).relative_to(dir_path)
                     for p in glob(f"{dir_path}/**/*.{extension}",
                     recursive=True)]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…