Load images matching
Load the images that match — a folder-aware matching loader
- images
- filename
- path
- matched_text
- found
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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| source_folder_path | STRING | — | |
| matching_root_path | STRING | — | |
| match_text | STRING | — | |
| match_mode | COMBO | 2 options: contains, exact | |
| recursive | BOOLEAN | true | — |
| index | INT | 00–999999 | — |
| step | INT | 11–9999 | — |
| repeat_count | INT | 11–9999 | — |
| context_folder_names | STRING | Nam Nu | — |
| source_file_namesopt | STRING | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| filename | STRING | — |
| path | STRING | — |
| matched_text | STRING | — |
| found | BOOLEAN | — |