Nodes/ComfyUI-Batch-Process/Text Modify Tool
ComfyUI Node

Text Modify Tool

A search-and-replace sidekick for this pack's loaders

By Zar4X·Created about a year ago·Updated 10 days ago· 16
Text Modify Tool
    • STRING
    input_text
    search
    change_to
    delimiter
    optionwhole texts
    deletefalse

    Text Modify Tool is the pack's little text-edit utility, and it's best understood as a filename scrubber. It takes one string in, runs a search-and-replace on it, and hands back one string out. Its natural home is sitting between a batch loader and a batch saver - say, cleaning up a filename the Image Batch Loader handed you before you use it as an output prefix.

    Let's be blunt about it: as a general text node it's nothing special, and if all you need is to munge arbitrary strings there are beefier packs (WAS Suite, rgthree, and friends) with more knobs. Where this one earns its keep is that it's tuned for the job this pack actually does - tidying names - and it chains cleanly with the loaders on either side. It's also the least-used node in the pack, so you're probably here because a workflow you downloaded references it. That's fine; it works.

    How it works

    Three inputs drive it: input_text, search, and change_to. If search is empty, it skips straight to rebuilding the text from change_to; otherwise it replaces every match of search with change_to. The delete toggle turns change_to into "replace with nothing" - a quick way to strip a word out of a filename without typing an empty string.

    option decides where the edit applies:

    • whole texts - replaces across the whole string, with one important quirk: it treats the input as a filename and strips the extension first (via os.path.splitext). Feed it photo_v2.png and it edits photo_v2, not the extension. That's intentional, and it'll bite you if you feed it prompt text and wonder where your punctuation went.
    • prefix - only edits the part before the first separator. If delimiter is empty it auto-detects one of -, _, --, or #.
    • suffix - same idea, but the part after the last separator.

    The single output is STRING, and it just flows into whatever text input you're feeding - a prompt field, a saver's contents, a show-text node.

    Installing it

    It's part of Zar4X/ComfyUI-Batch-Process, installed like the rest of the pack. In ComfyUI Manager search ComfyUI-Batch-Process, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Zar4X/ComfyUI-Batch-Process
    

    Then restart. Dependencies are just Pillow and torch, which ComfyUI already has.

    Troubleshooting

    The classic confusion is the extension stripping in whole texts mode - if your output looks truncated, that's the os.path.splitext behavior, not data loss. Second gotcha: with prefix or suffix and no delimiter, it auto-guesses separators from a hardcoded list, so a filename separated by, say, a space won't split the way you expect. If you need reliable splits, pass an explicit delimiter instead of letting it guess. And if nothing changes, double-check delete - it's easy to leave on and watch your replacement silently become a removal.

    Categorytext_processing

    Inputs (6)

    NameTypeDefaultDescription
    input_textSTRING
    searchoptSTRING
    change_tooptSTRING
    delimiteroptSTRING
    optionoptCOMBOwhole texts3 options: whole texts, prefix, suffix
    deleteoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    STRINGSTRING