Batch Image Iterator
The \"loop\" node that's really an index picker
- images
- image
- filename
The pack name promises a loop. The reality is smaller, and honestly more useful than it sounds: Batch Image Iterator pulls exactly one image out of an image batch, paired with its original filename. That's the whole job. If you've ever tried to batch-process a folder of images in ComfyUI - a genuinely notorious pain point on r/comfyui, where people end up writing their own scripts because "directory loader nodes don't auto-increment" - this is the missing middle piece.
Where it sits
The cedarconnor/comfyui-BatchNameLoop pack is a tiny four-node pipeline. Batch Image Loader reads every matching file out of a folder into one big IMAGE tensor plus a list of filenames, and the Iterator is what lets you work with those images one at a time. It's designed to sit between the loader and your processing nodes - upscale, inpaint, whatever - and hand each frame forward on its own.
How it actually works
Read the source and you'll find it's embarrassingly simple:
current_image = images[index:index+1]
current_filename = filenames[index]
One slice, one list lookup. But there's a genuinely nice safety net hiding in there: if your index exceeds the batch size, it wraps around with index % len(images) instead of erroring. Index 27 on a 10-image batch silently gives you image 7. That's a feature right up until it's a bug - it means you can't crash this node with a big number, you just get a wrong-but-valid image.
Three inputs, and you'll actually set two of them:
images- the batch, straight from the Loader (or anywhere that emits anIMAGEbatch).filenames- the Loader's filename list. The schema types it as a single STRING, but the node quietly accepts a list too, which is how it ends up wired in practice.index- the integer that decides which image comes out. Default 0.
Outputs are image (a one-image batch - note it keeps the batch dimension, so anything expecting an IMAGE is happy) and filename (the matching original filename as a plain string).
The honest part: it's not really a loop
"Loop" in the pack name oversells it. This node runs once per queue execution and hands you one image. The actual looping is you: change the index widget and re-run, or drive the index from another node or a script. If your goal is "run this whole folder unattended," you have two better options - let your downstream nodes process the entire batch in one pass (many do), or skip this pack and use a proper iterate framework like Inspire or Impact. Where the Iterator genuinely shines is when you need to handle frames individually, with a per-image step a batch can't express.
Install
Same story as every node in this pack - trivial, no models, no extra Python:
cd ComfyUI/custom_nodes
git clone https://github.com/cedarconnor/comfyui-BatchNameLoop
Restart ComfyUI, or search "Batch Name Loop" in ComfyUI Manager and hit install. The pack has no requirements.txt - it only touches Pillow, torch and numpy, all of which ComfyUI already ships - so there are no dependency fights to clean up afterward.
Gotchas
- The Loader flattens everything to RGB.
ImageOps.exif_transposeplusconvert("RGB")means alpha channels are silently dropped, so transparent PNGs come out opaque. If that matters, this pack isn't your loader. - Files that fail to load are skipped with a console error rather than a hard stop - which is friendly, but also easy to miss.
- Zero Google impressions and a single "Initial commit" tell you what this is: a small MIT-licensed utility pack a dev made for their own folder workflows. The code is short enough to read in a minute - do that before you trust it with anything precious.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| filenames | STRING | — | |
| index | INT | 0 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| filename | STRING | — |