List Dir
Enumerate files in a folder and feed them straight into a batch
- STRING
- PYLIST
- length
You've got a folder of a hundred PNGs you want to run through the same pipeline - batch upscale, batch caption, batch ControlNet preprocess, whatever. List Dir globs a folder and hands you the matches as a ComfyUI List, ready to wire into a loader and let the graph run once per file. It's the node that turns "here's a folder" into "here's a batch job."
How it works
Give it a path and a glob pattern. It runs Path(path).glob(pattern) under the hood - * matches everything in that one folder, *.png matches just PNGs, **/*.json walks subfolders recursively for JSON files. Whatever matches comes back as both a ComfyUI List (for per-item execution) and a PYLIST (one bundled array), plus a length telling you how many matches it found.
One detail worth knowing before you wire this to something downstream: the output tooltip is explicit that the values are Path objects, not plain Python strings, even though the socket is typed STRING. Most nodes that expect a filesystem path will happily accept a Path object without complaint - Python's pathlib.Path implements the same string-like protocol most file-handling code expects - but if you feed the output into something that does string-specific operations (like a literal .endswith(".png") check, or string concatenation with +) rather than path operations, you can hit surprising type errors. If that happens, run the value through Any Cast set to STRING first, which does an actual Python string conversion rather than just relabeling the socket.
The inputs and outputs that matter
path(default empty) - the folder to list. No browse button here, you type or paste the path.pattern(default*) - the glob pattern.*.pngfor one extension,**/*.extto recurse into subfolders,*for everything.
Three outputs: STRING as a ComfyUI List (is_list: true, values are Path objects) for per-item execution across your matched files, PYLIST as one bundled array of the same matches, and length, the match count - a fast way to confirm your pattern actually found what you expected before you kick off a long batch run.
How to install it
Through ComfyUI Manager, search "ComfyUI-List-Utils" and install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/godmt/ComfyUI-List-Utils.git
Restart ComfyUI. No models, no external dependencies - Path.glob is Python standard library, so this node is as install-light as the rest of the pack.
Common issues & troubleshooting
Zero matches, length comes back 0. Almost always a path or pattern issue. Double-check the path exists and is spelled correctly relative to wherever ComfyUI's process actually runs from - a relative path that works when you launch ComfyUI from one directory can silently fail to resolve when launched from another. Absolute paths sidestep the ambiguity entirely.
Pattern matches files in the top folder but misses ones in subfolders. A plain *.png only looks in the folder you gave it, one level deep. For recursive matching across subfolders, you need the **/ prefix: **/*.png.
Downstream node throws a type error on the file path. That's the Path-object-versus-string distinction above. Cast through Any Cast (type STRING) if the node genuinely needs a plain Python string rather than a path-like object.
Files come back in an order you didn't expect. Path.glob doesn't guarantee alphabetical or any particular order - it depends on the filesystem's own directory listing order. If processing order matters, sort the resulting PYLIST yourself with an Exec node before converting back to a List.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | Folder path to list. | |
| pattern | STRING | * | Pattern passed to Path.glob, for example *.png or **/*.json. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | Matched items as a ComfyUI List-processing output. Values are Path objects. |
| PYLIST | PYLIST | Matched items as one Python list value. |
| length | INT | Number of matched items. |