Nodes/Comfyui_TextBatch_aidec/Text Split Counter
ComfyUI Node

Text Split Counter

Count how many items are in your batch list

By aidec·Created 2 years ago·Updated 9 months ago· 19
Text Split Counter
    • count
    • status
    input_modefile
    text_fileEnter the path to your text file here
    input_textEnter your text here...
    separator_typenewline
    separator---

    Text Split Counter answers one question: how many items are in this list? Give it a block of text - or a text file - and a separator, and it tells you how many pieces it splits into. That's it. It's the "how long is my batch" node for aidec's text-batch pack.

    Sounds trivial, and mechanically it is. But it's genuinely useful as a companion to the queue nodes, because those nodes walk a list without you necessarily knowing up front how long the list is. Wire Text Split Counter to the same text and now you've got the total as a number you can use - to set a loop cap, to feed a progress readout, or just to sanity-check that your file actually parsed into the 340 prompts you think it has and not one giant blob because the separator was wrong.

    How it works

    It reads your text from wherever you point it, splits on the separator, and counts the resulting chunks. No state, no counter that advances, no re-queuing - unlike the queue processors, this one just looks at the whole list and reports its length in a single pass. Which also makes it the fastest way to verify your split before you commit to a long batch run.

    The inputs that matter

    • input_mode - file or text. Note the default here is file, so if you're typing into the box, switch it to text first. This trips people up.
    • text_file - the path, in file mode.
    • input_text - the box, in text mode.
    • separator_type / separator - how the list is divided. newline for one item per line, or custom with separator set to whatever your file actually uses (the pack defaults this to --- for multi-line blocks). This has to match how your batch nodes are splitting, or the count won't agree with reality.

    Outputs are just count (the number of items) and status. Feed count into anything that wants your batch length - Image Queue Processor Plus's max_index, a text overlay, a comparison node.

    Installing it

    cd ComfyUI/custom_nodes && git clone https://github.com/aidec/Comfyui_TextBatch_aidec, then restart ComfyUI (or ComfyUI Manager → Install via Git URL). No models, no heavy dependencies. Category: TextBatch.

    Where people get burned

    • Separator mismatch is the whole ballgame. If Text Split Counter says "1" and you expected 50, your separator doesn't match your file. Newline-separated file but the node's set to split on ---? One chunk. Get this node agreeing with your actual batch nodes before you trust the number - that's precisely what it's good for.
    • Default is file mode. If you paste prompts into input_text but leave input_mode on file, it'll try to read a path called "Enter your text here..." and give you nonsense. Flip to text mode.
    • File paths are server-side. On a hosted ComfyUI the file has to live on the server, not your local disk.

    It's a checking tool more than a building tool. Use it to confirm your list is the length you think, then let the queue nodes do the actual walking.

    CategoryTextBatch

    Inputs (5)

    NameTypeDefaultDescription
    input_modeCOMBOfile2 options: file, text
    text_fileSTRINGEnter the path to your text file here
    input_textSTRINGEnter your text here...
    separator_typeCOMBOnewline2 options: newline, custom
    separatorSTRING---

    Outputs (2)

    NameTypeDescription
    countINT
    statusSTRING