Nodes/ComfyUI-My-Nodes/提示词逐行读取
ComfyUI Node

提示词逐行读取

Feed a batch job one prompt per line from a plain text file

By Tagbliton·Created 2 years ago·Updated about a year ago· 11
提示词逐行读取
    • text
    • index
    • lines
    file_name
    index0

    If you've ever wanted to run fifty images from fifty different prompts without hand-editing a text box between each run, this node is your friend. It reads a plain-text file where each line is a prompt, pulls out the line at a given index, and hands you that line as a STRING. Drive the index from a loop counter and you've got a batch prompt reader with no CSV, no wildcard system, no plugin - just a .txt file and an integer.

    The mechanism is about as simple as it gets: the node lists .txt files from a dedicated prompt folder (the pack auto-creates ComfyUI/models/prompt/ on load and registers it, so drop your files there), opens the selected file_name, reads all lines, and returns the one at index. Three outputs come back: text (the line, with surrounding whitespace stripped), index (the same index you passed in, echoed for convenience), and lines (the total line count). That lines output is the sleeper feature - wire it into a loop's max-count and your batch automatically sizes itself to the file instead of overrunning it.

    The two inputs: file_name (a dropdown of .txt files in that prompt folder) and index (an INT, default 0, range 0–9999).

    The classic wiring is the easyuse-style loop the pack's README is clearly aimed at: a loop node increments index, this reader fetches prompt line i, that prompt feeds the sampler, repeat. Combined with the pack's "重置/重复索引" (which resets or repeats an index at a given step), you can build a batch that recycles the same prompts cyclically.

    Install: part of ComfyUI-My-Nodes - ComfyUI Manager → search "ComfyUI-My-Nodes", or git clone https://github.com/Tagbliton/ComfyUI-My-Nodes into custom_nodes and restart. No API key, no network - local utility.

    Gotchas. The file location matters: it reads from ComfyUI/models/prompt/ (which the pack creates), not your input folder. Put the file in the wrong place and it won't show in the dropdown. If index is out of range - greater than or equal to the line count - the node raises an error telling you the valid range, rather than returning an empty string. Also note it splits on newlines literally, so a file with Windows line endings or trailing blank lines will treat the blanks as "prompts" (stripped to empty strings) - keep the file clean, one prompt per line, no trailing newline, and the lines output will match what you think it is.

    Category我的节点/Tools

    Inputs (2)

    NameTypeDefaultDescription
    file_nameCOMBO0 options:
    indexINT00–9999

    Outputs (3)

    NameTypeDescription
    textSTRING
    indexINT
    linesINT