Nodes/ComfyUI Warper Nodes/Load Single Prompt by Index (Warper)
ComfyUI Node

Load Single Prompt by Index (Warper)

One prompt, precisely, from a folder

By AIWarper·Created about a year ago·Updated 8 months ago· 14
Load Single Prompt by Index (Warper)
    • prompt
    • file_name
    • total_files
    • is_valid
    directory_path
    file_index0

    Sometimes you don't want a folder of prompts dumped at once - you want exactly one prompt, and you want to know you got it. Load Single Prompt by Index (Warper) reads one .txt file out of a directory by its 0-based position in the sorted list. Drive the file_index with an integer counter and you've got sequential access to a prompt library with zero graph edits: bump the counter, get the next prompt. The README frames it as "ideal for workflows that need to process prompts one at a time with precise index control," and that's the whole pitch.

    It's the focused cousin of Load Prompts from Directory (Warper) in the ComfyUI Warper Nodes pack from workflow author AIWarper. Same folder-of-txt-file idea, different shape: that one returns a list, this one returns a single prompt plus enough metadata to know whether the load actually worked.

    How it works

    Two inputs:

    • directory_path - folder of .txt files (absolute path is safest; ~ expands).
    • file_index - which file, 0-based. Default 0, up to 10000.

    It globs *.txt, sorts by filename, and reads the one at your index, stripping whitespace. Four outputs make it friendly to build logic around:

    • prompt - the text (empty string on failure).
    • file_name - which file was read, so you can label outputs.
    • total_files - how many .txt files exist, so you know the bounds.
    • is_valid - a BOOLEAN saying whether the read succeeded. This is the output that makes the node genuinely useful: you can branch on it instead of guessing.

    If the index is out of range, you get an empty prompt, the real total_files, and is_valid false - a clean, checkable failure instead of a crash.

    Installing it

    Standard Warper install: ComfyUI Manager → search "ComfyUI-WarperNodes" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AIWarper/ComfyUI-WarperNodes
    # restart ComfyUI
    

    No model, no extra pip packages. The README's RAFT checkpoint is for Flow Visualizer and irrelevant here.

    Common issues

    The design decision to lean on is is_valid - it exists precisely because the failure mode is otherwise silent. An empty prompt can mean "index out of range" or "empty file" or "directory missing," and only is_valid separates those cleanly; if you don't check it, an out-of-range counter feeds an empty prompt into your sampler and you get a junk image with no error. Filenames sort lexically, so "prompt10.txt" sorts before "prompt2.txt" - zero-pad your names if order matters. And one run, one prompt: this node holds no state, so it's the right tool when you want deterministic, index-driven selection rather than the remembered-position behavior of the pack's Text File Iterator.

    CategoryWarper Tools/Prompts

    Inputs (2)

    NameTypeDefaultDescription
    directory_pathSTRING
    file_indexINT00–10000

    Outputs (4)

    NameTypeDescription
    promptSTRING
    file_nameSTRING
    total_filesINT
    is_validBOOLEAN