🎈LG_图片列表加载器
Load one folder, get every image, one at a time, in order
- images
- masks
- filenames
- current_index
- total_images
LG_ImageLoaderWithCounter (🎈LG_图片列表加载器) is a folder loader with a counter built in. Point it at a directory full of images, and every time you queue it pulls the next one - in a controlled order, wrapping around when it hits the end. No external counter node, no seed-to-index wiring, no manual file renaming. It's the "process a whole folder in sequence" node that ComfyUI's default loader makes you assemble by hand.
The README is unusually detailed here (the author clearly uses this one a lot), and it's worth reading before you build your own loop. The core idea: the counter lives inside the loader, so the node knows how many images are in the folder, remembers where you are, and advances on each execution.
The inputs that matter
folder_path(STRING) - the folder of images. Absolute paths work; relative paths are resolved from the ComfyUI root directory. Supported formats: jpg, jpeg, png, bmp, gif, webp, tiff, tif.mode(enum) -increase(next image each run, wraps around),decrease(previous image each run), orall(load the entire folder as a list in one go, for batch nodes).sort_mode(enum) - how the folder is ordered: Alphabetical ASC/DESC, Numerical ASC/DESC (natural number sorting, soimg2<img10), or Datetime ASC/DESC (by file modification time). Pick Datetime when you want "process in the order I shot them."keep_index(BOOLEAN, default false) - pause the counter. On, it stays on the current image across runs - perfect when you're iterating on one image and don't want the batch to advance.
What comes out
Five outputs: images and masks (IMAGE/MASK lists), filenames (STRING list), plus current_index and total_images (INT). The counter values are what make it workflow-friendly - feed current_index into a text node for naming, or use total_images to size a loop. In increase/decrease mode the image/mask lists contain a single element; in all mode they contain everything.
How the counter behaves
Increment and decrement both auto-cycle (you hit the end and it wraps to the start). Changing folder_path or sort_mode resets the index, and there's a refresh button on the node that re-scans the folder and resets the counter. If you've ever fought a stale file list after adding images mid-session, that refresh button is the fix.
Installing it
Part of Comfyui_LG_Tools:
cd ComfyUI/custom_nodes
git clone https://github.com/LAOGOU-666/Comfyui_LG_Tools.git
pip install -r requirements.txt
Or via ComfyUI Manager → "Comfyui_LG_Tools" → restart. It's under Add Node → 🎈LAOGOU → Utils.
Common issues
- "It loads nothing." The path is wrong, or relative and not resolvable from the ComfyUI root. Check the console for the "folder doesn't exist" message.
- "It's skipping my files." If filenames have numbers and you picked Alphabetical,
10.jpgsorts before2.jpg. Switch to Numerical (ASC) for natural ordering. - "The queue keeps advancing when I don't want it to." That's
keep_index's job - turn it on while you're testing a single image. - Lists, not single images. Everything image-ish comes out as a list. If a downstream node wants a plain IMAGE, you may need a list-unpacking step or batch mode.
If you're doing folder-to-batch processing in ComfyUI, this is the node that saves you from the tangle of counters and index math. It's one of the genuinely thought-through utilities in this pack.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | — | |
| mode | COMBO | increase | increase: 递增模式,decrease: 递减模式,all: 加载所有图像 |
| sort_mode | COMBO | Alphabetical (ASC) | 图片排序方式 |
| keep_index | BOOLEAN | false | 开启时保持当前索引不变,关闭时恢复正常递增/递减 |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| masks | MASK | — |
| filenames | STRING | — |
| current_index | INT | — |
| total_images | INT | — |