Nodes/ComfyUI Video BC/Text Batch Replace
ComfyUI Node

Text Batch Replace

Fix fifty prompts without touching each one

By JioJe·Created about a year ago·Updated 5 months ago· 14
Text Batch Replace
  • batch_texts
  • replaced_texts
search_1
replace_1
search_2
replace_2
search_3
replace_3

If Text Batch Loader got your whole folder into one list, this is the node that cleans it up before it goes anywhere else. Text Batch Replace applies up to three search-and-replace pairs to every string in a batch, and hands you back a new list of the same length.

Here's the thing to know up front: this is literal text replacement - str.replace(), exactly what it sounds like. Not regex. Not case-insensitive. If the search string doesn't appear verbatim in a line, that line is left untouched. For most prompt-batch cleanup that's a feature - but it means "MASTERPIECE" will not match "masterpiece", and it means a search for "masterpiece" won't touch "masterpiece, " the way you'd hope. That trailing comma is the difference between "worked" and "silently did nothing," so check your whitespace.

Inputs:

  • batch_texts (LIST) - the strings to transform.
  • search_1 / replace_1, search_2 / replace_2, search_3 / replace_3 - three pairs of plain strings. Leave a search empty and that pair is skipped, so you can use one, two, or all three pairs per run.

Output: replaced_texts (LIST), same order as the input.

Because pairs apply sequentially, order can matter in a way that surprises people: if pair 1 inserts the exact word that pair 2 is looking for, pair 2 will hit your freshly inserted text. Usually that's harmless, but if a replacement is misbehaving, walk the pairs one at a time.

Real-world uses, in order of how often I see them: stripping a shared prefix like masterpiece, best quality, from a folder of tags, swapping an artist's name across a whole batch before a re-generation, or normalizing punctuation so a batch matches what a tagger expects. Pair it with Loader upstream and Saver downstream and you have a small text-munging pipeline that touches no pixels.

Install is the pack-standard: ComfyUI Manager → search "ComfyUI Video BC", or cd ComfyUI/custom_nodes && git clone https://github.com/JioJe/comfyui_video_BC and restart. No dependencies beyond what ComfyUI already ships for the text nodes, no models to download. If you need actual regex or case-insensitive matching, this node isn't it - but for the 90% case of "clean up a folder of prompts," it does the job with zero ceremony.

CategoryBC/Text

Inputs (7)

NameTypeDefaultDescription
batch_textsLIST
search_1STRING
replace_1STRING
search_2STRING
replace_2STRING
search_3STRING
replace_3STRING

Outputs (1)

NameTypeDescription
replaced_textsLIST