INNER CODE UNIT · Python

get_relpaths_matching_subdirs

mfarragher/obsidiantools · obsidiantools/_io.py:27

def get_relpaths_matching_subdirs(dir_path: Path, *,
                                  extension: str,
                                  include_subdirs: list = None,
                                  include_root: bool = True) -> list[Path]:
    """Get list of relative paths for {extension} files in a given directory,
    filtered to include specified subdirectories (with include_subdirs
    kwarg).  The default arguments align with get_relpaths_from_dir
    function, but this function enables more flexibility.

    For example, if you had a vault with folders named by category, and
    filter them like this in Obsidian:
        path:Category1/ OR path:Category2/ OR path:Category4/
    then you can use the include_subdirs kwarg to do that with this function:
        include_subdirs = ['Category1', 'Category2', 'Category4']

    You can also specify deeper levels to filter on, e.g.:
        include_subdirs = ['Category1/TopicA', 'Category1/TopicB']

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…