Nodes/comfyui-toml-prompt/StringConcatInt
ComfyUI Node

StringConcatInt

Stitching a number onto the end of your filename

By morino-kumasan·Created 2 years ago·Updated a day ago· 1
StringConcatInt
    • STRING
    text_from
    text_to
    sep

    Want your saved images named portrait_958570523456296.png instead of whatever SaveImage's prefix-plus-counter gives you? StringConcatInt is the two-second answer: it takes a number and a string, glues them together with a separator you choose, and gives you a STRING you can wire into a filename prefix.

    I know how that sounds. "Concatenate a string and an int" is not the kind of node anyone gets excited about. But filename prefixes are exactly where the plumbing pays off - you want the seed in there so you can find a generation again, and the seed lives on a seed output, which is an INT, and the prefix widget wants a STRING. Something has to bridge that.

    How it works

    def concat(self, text_from: int, text_to: str, sep: str):
        return (text_to + sep + str(text_from),)
    

    The int is stringified and appended after the string with your separator between them.

    Read the argument names carefully, because they're backwards relative to the output: text_to comes first in the result, text_from comes last. The names describe "text that goes to X" rather than positions, and the same quirk exists on the sibling StringConcat node (text_to + sep + text_from). Ninety percent of the confusion this node causes is someone wiring the seed into text_from expecting it at the front.

    sep is a normal string input, so "_" gives portrait_12345, an empty string gives portrait12345, and you can pass something longer like " - seed " without fighting the node.

    Inputs and outputs

    text_from (INT, the number - the tooltip says "Text to.", which is the copy-paste artefact of the sibling node), text_to (STRING, multiline, "Text from."), sep (STRING, "Join separator."). One STRING output. Wire it into SaveImage's filename_prefix, or into a note, or into a string node you keep visible.

    Install

    Manager search for the pack, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/morino-kumasan/comfyui-toml-prompt
    

    restart ComfyUI. Nothing to install - requirements.txt is empty, and the whole node is a str() and two +. The README's install block is out of date (old repo name, SSH clone URL); use the HTTPS URL above.

    Where people get burned

    The reversed order. Repeat after me: text_to is the front half. If your filenames come out as 958570523456296_portrait, you've swapped them.

    A seed that changes per run. Wire a randomize seed into your filename and every generation gets a new name - which is either exactly what you want, or the reason your output folder is unreadable. Lock the seed when you're iterating on a single image.

    Filename-prefix characters are not sanitised by this node. SaveImage will happily take your separator and build a path with it, so a / in sep creates a subfolder and a stray : on a non-Windows box is legal-but-ugly. Keep separators boring.

    Categoryutils

    Inputs (3)

    NameTypeDefaultDescription
    text_fromINT-9223372036854776000–9223372036854776000Text to.
    text_toSTRINGText from.
    sepSTRINGJoin separator.

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGA text.