获取路径图片地址
Turn a folder of images into a list of paths
- 图片路径列表
LoadDirImgPaths ("获取路径图片地址", get image paths from directory) points at a folder and hands you back a list of every image file path inside it - recursively. It doesn't load the images, doesn't resize them, doesn't care what's in them. It produces strings, and strings are the useful thing when you're building a batch workflow.
The reason this node exists is that core ComfyUI's image loader is a dropdown of files it already knows about, and it's not built for "run this once per file in a folder." If you've got a directory of reference images, frames, or products that changes between runs, you want a node that walks the folder at queue time and returns paths you can feed to a load-by-path node or loop over. That's this. The pack pairs it naturally with its loop nodes and with the LamLoadPathImage-style loaders, but the output is a plain LIST of strings, so any node that eats a list will work.
How it works
Under the hood it's os.walk over whatever directory you give it, filtering to .jpg, .jpeg, .png, .gif, .bmp, .tif, and .tiff. Every match gets its full path appended to the output list. Two behaviors worth knowing:
- If the directory doesn't exist, it raises an exception (
路径不存在- "path does not exist") rather than returning an empty list. So a typo in the path is loud, not silent. - Its
IS_CHANGEDmethod always reports changed, which means ComfyUI re-runs it on every queue instead of caching the result. For a node whose whole job is "see what's in the folder right now," that's the correct behavior - drop a new file in and it shows up without you hunting for a cache-busting widget.
The order follows the filesystem walk, not a sorted filename order. If order matters to you, sort downstream.
The inputs and output
input_img_dir- the folder path. Use an absolute path; a relative one resolves against ComfyUI's working directory, which is not where you think it is.- Output
图片路径列表("image path list") - aLISTof full file paths.
That's the whole node. One string in, one list out.
Installing it
ComfyUI_Lam's a single pack - search "ComfyUI_Lam" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam
Restart, and it shows up in the lam category. No model files needed for this node - it's pure Python path handling.
Common issues
The classic mistakes are relative paths and trailing-slash confusion. Give it D:\reference\frames or /home/me/frames and it's happy. And because the output is a list of paths, don't plug it straight into a core LoadImage node - that wants the dropdown. Feed the paths into a loader that accepts a path string, or index them with something like the pack's LongTextToList or a select node.
One thing to keep in mind about the pack in general: the README's full install procedure (the bundled rar extraction, the pinned pip requirements from the Aliyun mirror) is aimed at the pack's heavy nodes - face fusion, talking-head, inpainting. You don't need any of it for this node, and installing all of it is a real risk of breaking your Python environment with numpy 1.23.4. If the pack already came in via Manager and this node is all you use, leave the heavy install alone. And if you ever uninstall the pack and a Chinese popup keeps appearing at launch, delete ComfyUI/web/extensions/lam to clear the leftover frontend extension.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| input_img_dir | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 图片路径列表 | LIST | — |