Nodes/ComfyUI_BatchImages/RHBatchImages:
ComfyUI Node

RHBatchImages:

ComfyUI's index-expression filter

By kegeai888·Created 4 months ago·Updated 4 months ago· 0
RHBatchImages:
  • images
  • image
  • selected_manifest
image_indices0-100
manifest[]

Stock ComfyUI is all-or-nothing with a batch: you either run every image through the same nodes or you start deleting wires. RHBatchImages: is the middle node of the ComfyUI_BatchImages pack, and it exists to say "no - just these ones." Give it a list of images and a short text expression, and it hands back the exact subset you asked for, with the metadata to match.

What it's for

You upload a zip with RHUploadZip_V2, you've got 200 images queued, and then you notice image 3 is corrupted and the last ten are duplicates. Or you only want to test the pipeline on the first ten before committing a full run. Type 0-9 into image_indices, hit go, and you're not wasting a pass on the junk. It's also how you carve out a "holdout" set for a training run without building a second graph - same idea as the index slicing people do by hand in dataset scripts, but inside the node graph.

How it works

Three inputs, and really only one you'll touch:

  • images - the IMAGE list from the uploader (or anywhere else).
  • image_indices - a string, default 0-100. This is the whole node. It parses a small expression language: single indices (0), comma lists (0,2,5), inclusive ranges (0-3), and mixes of all three (0,2-4,7). Everything is zero-based.
  • manifest - the JSON string from the uploader; the node re-indexes it in lockstep so your filenames stay correct downstream.

Out of range is ignored rather than an error, duplicates are kept once, and the output preserves input order. A malformed expression - or an expression that produces zero valid indices - is a hard error, so you can't silently run an empty batch.

It outputs image (the filtered IMAGE list) and selected_manifest (the matching JSON), both renumbered so the manifest still lines up with the list. It also refuses to run if images and manifest disagree on length - that check catches a lot of "why is my output wrong" before it happens.

The trailing colon is real

The class name is literally RHBatchImages: with a colon on the end, and that's how it appears in the node menu too. It's a quirk, not a typo on comfy.icu. If you're searching the node list in ComfyUI Manager or pasting node names around, keep the colon or the search won't match.

The trap to know about

The default 0-100 looks like "the first hundred," but it's really "indices 0 through 100, clipped to whatever exists." With 12 images that's all of them; with 150 it's the first 101. And because out-of-range is silently ignored, a typo like 1-50 when you meant 10-50 just quietly gives you fewer images - the graph doesn't complain, and the save node downstream still runs. If the count surprises you, that's the first thing to check. Batch runs are expensive; verify the selection before you let it rip.

Install and dependencies

Same story as the rest of the pack - this is the good kind of custom node:

cd ComfyUI/custom_nodes
git clone https://github.com/kegeai888/ComfyUI_BatchImages

Restart ComfyUI and it appears under BatchImages. No requirements.txt, no model downloads, nothing beyond what ComfyUI already has. It may show up in ComfyUI Manager's search too, but with zero dependencies the manual clone is just as fast. One line of image_indices syntax and one edge case is the entire learning curve here - this is the least fiddly node in the whole batch workflow.

CategoryBatchImages

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
image_indicesSTRING0-100
manifestSTRING[]

Outputs (2)

NameTypeDescription
imageIMAGE
selected_manifestSTRING