Nodes/Mickmumpitz-Nodes/Iter String Selector
ComfyUI Node

Iter String Selector

The right prompt for the current iteration, automatically

By mickmumpitz·Created 8 months ago·Updated 9 days ago· 47
Iter String Selector
  • string_batch
  • string

In iterative video, the prompt shouldn't stay static - scene two needs different words than scene one. But wiring each prompt to its own iteration by hand means managing a mess of switches. Iter String Selector does it for you: it takes a STRING_BATCH of per-iteration prompts and, based on the current iteration number, returns the one that matches. No manual widget, no rewiring as the loop runs.

It's the string-side cousin of Iter Seed Batch in the pack's video/iteration family, and it works because it reads the same hidden iteration context that the rest of the loop uses. Where the manual String Selector node asks you to type a number, this one just knows.

How it works

The node takes one input, string_batch (STRING_BATCH), and a hidden iteration integer that ComfyUI supplies. On iteration N, it returns the N-th string. The useful subtlety is the fallback behavior: if the current iteration's string is empty or out of range, it falls back to the last non-empty string seen so far. So you can leave gaps in your prompt list - iterations that don't need a change just ride on the previous prompt instead of breaking the loop or emitting an empty string.

Concretely, with ["a dark street", "", "a rooftop at dawn"]:

  • iteration 0 → "a dark street"
  • iteration 1 → "a dark street" (blank slot → fallback)
  • iteration 2 → "a rooftop at dawn"

That's the whole mechanism. string_batch in, one string out.

Where it fits

Feed it the string_batch from Iter Prompt Builder (which batches your per-iteration prompts) and wire the string output into your CLIP text encode. Iteration 0 runs the first prompt, later iterations pick up their own - with blanks handled gracefully. Pair it with Iter Seed Batch for the matching seed behavior and you've got a loop where every pass has its own prompt and seed, both driven by the same iteration counter.

Installing

Part of Mickmumpitz-Nodes - ComfyUI Manager → search "Mickmumpitz" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/mickmumpitz/ComfyUI-Mickmumpitz-Nodes

Light deps (numpy, Pillow, opencv-python), nothing to download.

Gotchas

Like Iteration Switch, this node only does its thing inside the pack's iteration machinery - outside a pack-managed loop, the hidden iteration defaults to 0 and you'll always get the first string. That's correct behavior, just surprising the first time. Also note the fallback is "last non-empty," so a blank string mid-list doesn't reset the prompt - if you genuinely want an empty prompt at some iteration, you can't express it with a blank slot; use a space or a sentinel and handle it downstream.

CategoryMickmumpitz/video/iteration

Inputs (1)

NameTypeDefaultDescription
string_batchSTRING_BATCH

Outputs (1)

NameTypeDescription
stringSTRING