Split Batch With Prefix
Un-batch images into individually named saves
- images
- image
- name
ComfyUI renders a batch of N images as one IMAGE tensor with N frames, and a stock SaveImage saves them all in one go - which is fine until you want each image saved under its own index-based filename, or fed through something that works one image at a time. Split Batch With Prefix takes that batch and hands it out one image per queue run, each named with an incrementing index plus your chosen prefix.
The concrete use case from the README: you have a 5-image batch, and you want the results named 0-SDXL_, 1-SDXL_, 2-SDXL_, … so every image lands with a matching index instead of a pile of timestamped files. It's a batch-unpacker for people who care about filenames.
How it works
The node is stateful. Each execution it looks at the batch tensor, takes the image at its current position (wrapping with modulo), and returns that single image plus a computed name. The position advances every call.
The name is built as {global_index + index}{filename} - where index is your starting offset, filename is the prefix (default _SDXL_), and the counter increments each run. If you set subfolder, it becomes {subfolder}/{counter}{filename}, and the subfolder supports a %date:yyyy-MM-dd% placeholder that expands to today's date.
The state resets when it detects a "new run": if index, filename, or subfolder change, or if the previous call was more than a second ago (a time-window heuristic so separate queue runs don't keep counting from a stale position). Same params, quick successive runs → continuous counting.
Inputs / outputs
images(required) - anIMAGEbatch tensor (e.g. straight from KSampler or a batch builder).subfolder- output subfolder path (supports%date:yyyy-MM-dd%).filename- the prefix that follows the index (default_SDXL_).index- starting number for the counter (default 0).- Outputs:
image(one image, for a SaveImage node) andname(the computed filename string, matching what SaveImage will produce given the same subfolder/filename).
Gotchas
- One image per queue run, not one per batch. If you want all five split in a single queue run, this isn't it - the point is to pair each image with a per-run index and a SaveImage. Loop or re-queue machinery in your graph drives the stepping.
- The "new run" detection is a 1-second timer. Keep your calls inside a second and it counts up continuously; let more than a second pass between executions and it resets to the start. That's a heuristic, so very slow steps (huge upscales) can reset the counter mid-batch. If filenames come out wrong, that's usually why.
- Name only matches SaveImage if you keep the convention. Give SaveImage the same
subfolderandfilename, and the file that lands on disk matches thenamestring output. Change one and they diverge. - It throws on non-image tensors. It expects
[B,H,W,C]; feeding it a latents or conditioning tensor is a hard error, not a silent pass-through.
Install
ComfyUI Manager (search "Santodan"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Santodan/santodan-custom-nodes-comfyui
Restart. No dependencies, no downloads.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| subfolder | STRING | — | |
| filename | STRING | _SDXL_ | — |
| index | INT | 00–9999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| name | STRING | — |