Nodes/NH-Nodes/Load images matching
ComfyUI Node

Load images matching

Load the images that match — a folder-aware matching loader

By jetthuangai·Created 5 months ago·Updated 21 days ago· 6
Load images matching
    • images
    • filename
    • path
    • matched_text
    • found
    source_folder_path
    matching_root_path
    match_text
    match_mode
    recursivetrue
    index0
    step1
    repeat_count1
    context_folder_namesNam Nu
    source_file_names

    Plain folder loaders give you an index and hope you know which number is which. Load images matching (class NH_LoadImagesMatching) is the loader that actually looks at your folder structure and matches images by name and folder context - the one you want when your sources live in named subfolders and you need the loader to figure out which one you mean. It ships in the NH-Nodes pack and it's clearly built for the author's garment/VTON workflows: the default context_folder_names is literally Nam / Nu (Vietnamese for male/female).

    How it works

    You give it a source_folder_path (where the images live) and a matching_root_path (the root that holds the context subfolders). It then walks the folder tree and scores candidate images against your match_text using match_mode - contains (loose substring) or exact - plus the context_folder_names list to disambiguate when two subfolders could match. The closest hit wins. This isn't a dumb "find files containing X" glob; it's a scorer that considers path context, which is why it exists.

    Selection controls mirror the other loaders: index and step for picking within matches, repeat_count to repeat the same image N times in the batch, recursive to descend subfolders, and an optional source_file_names list to constrain the search. Outputs are images, filename, path, matched_text (what it actually resolved), and a found BOOLEAN so you can branch when nothing matched.

    Where you'd actually use it

    Directory-organized sets: a folder of garment photos split into Nam/ and Nu/ subfolders, portraits by person, any "this category lives in that folder" structure. It's also a genuine always-rerun node - its IS_CHANGED returns NaN, so it re-scans the folder every run. That's deliberate: it's a live filesystem reader, and it means new files show up without you forcing a reload. Good for a batch that processes whatever landed in a folder since last run.

    Installing

    ComfyUI Manager → search NH-Nodes → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jetthuangai/NH-Nodes.git
    cd NH-Nodes
    pip install -r requirements.txt
    

    Restart and refresh the browser page.

    Gotchas

    The always-rerun behavior is a double-edged sword: it breaks ComfyUI's caching for everything upstream of the loader, so don't put one of these in the middle of a graph you run repeatedly if you want the downstream cache to survive. And because it's a scorer, a contains match in the wrong context folder can win - check the matched_text output before trusting a loaded batch. The found flag is there for a reason; wire it into a switch if a miss should route you somewhere else. It's the most specialized node in the loading trio, so if your files aren't organized into matching subfolders, the plain Load Images Folder (NH) is simpler.

    CategoryNH-Nodes/Image

    Inputs (10)

    NameTypeDefaultDescription
    source_folder_pathSTRING
    matching_root_pathSTRING
    match_textSTRING
    match_modeCOMBO2 options: contains, exact
    recursiveBOOLEANtrue
    indexINT00–999999
    stepINT11–9999
    repeat_countINT11–9999
    context_folder_namesSTRINGNam Nu
    source_file_namesoptSTRING

    Outputs (5)

    NameTypeDescription
    imagesIMAGE
    filenameSTRING
    pathSTRING
    matched_textSTRING
    foundBOOLEAN