ComfyUI Node

AZAll Batch Splitter

Chop one big text into scenes, chapters, or items

By cronos3k·Created 5 months ago·Updated 5 months ago· 0
AZAll Batch Splitter
    • first_section
    • all_sections
    • count
    text
    delimiter##
    skip_emptytrue

    The node for "now that the LLM wrote a whole script, give me each scene separately." AgentAZAll_BatchSplitter splits a big text block on a delimiter - by default the string ## (a markdown header) - and hands you the first section, all sections numbered, and the count. It's the bridge between a long generation and a pipeline that needs to process each part individually, which is exactly its job in the pack's Story → Video demo: the director writes a multi-scene script, and BatchSplitter carves it into per-scene prompts for downstream image generation.

    How it works

    It splits text on the delimiter string and, with skip_empty on (the default), drops any empty or whitespace-only chunks and strips the leftovers. The result: first_section gets the first chunk, all_sections gets every chunk rendered as === Section i/n === followed by the content, and count is an integer - how many sections came out. An empty delimiter is a degenerate case that returns the whole text as a single section.

    One thing to note: the default ## (with a trailing space) is chosen to match markdown ## Scene headers - the demo uses ## Scene delimiters and the space prevents partial matches like ## NotAScene. If your text uses a different marker, set the delimiter to match.

    The inputs that matter

    • text (required, forceInput) - the big block to split. Wire it from the LLM's response.
    • delimiter (default ## ) - the split point. Exact string match, so get the spacing right.
    • skip_empty (default true) - drop blank chunks after splitting.

    Three outputs: first_section (STRING), all_sections (STRING), and count (INT). Wire first_section somewhere you want "the first thing," or use count to drive a loop/condition downstream.

    Installing it

    Part of cronos3k/comfyui-agentazall - Manager search "AgentAZAll", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cronos3k/comfyui-agentazall.git
    pip install "agentazall>=1.0.13"
    # restart ComfyUI
    

    No models, no keys.

    Common issues

    Delimiter mismatch is the whole failure mode: if the text uses ##Scene without the space and your delimiter is ## , you'll get one giant section and a count of 1 - check your delimiter against the actual generated text before assuming the LLM produced valid sections. Also note all_sections re-formats with its own headers rather than returning the raw chunks, so if you need the unmodified text of a section, you're better off splitting yourself or handling sections upstream. And it's string splitting, not smart parsing - a delimiter that appears mid-sentence will split mid-sentence.

    CategoryAgentAZAll/Utility

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    delimiteroptSTRING##
    skip_emptyoptBOOLEANtrue

    Outputs (3)

    NameTypeDescription
    first_sectionSTRING
    all_sectionsSTRING
    countINT