Nodes/ComfyUI-nhknodes/πŸ“‚ Load Text Files (nhk)
ComfyUI Node

πŸ“‚ Load Text Files (nhk)

Cycle through saved text files like a prompt jukebox

By EnashkaΒ·Created 12 months agoΒ·Updated 28 days agoΒ· 23
πŸ“‚ Load Text Files (nhk)
    • text_content
    • loaded_filepath
    • available_count
    • current_filename
    • repeat_status
    β—„folder_pathβ–Ί
    β—„base_filenamesaved_textβ–Ί
    β—„file_extensiontxtβ–Ί
    β—„counter_format_{counter:03d}β–Ί
    β—„auto_incrementtrueβ–Ί
    β—„set_to0β–Ί
    β—„repeat_count1β–Ί
    β—„wrap_aroundtrueβ–Ί

    Sometimes the prompt you want to test isn't one string - it's a folder of saved prompts, and you want to cycle through them across a batch run without touching the UI between generations. LoadTextFiles is the node for exactly that: it scans a folder for numbered text files like saved_text_001.txt, loads them one at a time, and auto-advances to the next on every execution. It's the text-world equivalent of LoadImageSeries, and it lives in the nhk/text category of the nhknodes pack.

    The natural pairing is a SaveText-style node that writes saved_text_001.txt, saved_text_002.txt... on one side of a workflow and this loader replaying them on the other - a prompt file server that round-trips through disk.

    How it works

    The node builds a regex from your base_filename, counter_format, and file_extension, then scans the folder for every file that matches. The default counter_format of _{counter:03d} matches _001, _002, and so on - the {counter:03d} bit means "three digits, zero-padded." On each run it loads the current file's content and, if auto_increment is on, advances to the next index for the next run.

    Three knobs make it flexible beyond "just advance":

    • repeat_count (default 1) - load the same file this many times before moving on. Handy for generating a few variations per prompt.
    • wrap_around (default true) - after the last file, loop back to the first. Turn it off if you want the sequence to stop at the end instead.
    • set_to (default 0) - jump to a specific index mid-run. 0 means "continue from where I am," any positive value hops to that file.

    The folder_path input can be left empty, which silently falls back to ComfyUI's output directory - convenient when your saved text lives next to your generated images. Outputs: text_content (the file's text - feed it into a text encoder or prompt builder), loaded_filepath, available_count, current_filename, and repeat_status (a 1/3-style readout of where you are in the repeat cycle).

    Installing

    Standard pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Enashka/ComfyUI-nhknodes
    

    or ComfyUI Manager β†’ search "NHK Nodes" β†’ install β†’ restart. No models, no extra dependencies. It appears under nhk/text.

    Where people get burned

    • "Nothing loads, available_count is 0." Filename pattern mismatch. If your files are prompt_1.txt (no zero-padding) the default _{counter:03d} won't match - change the format to _{counter:d} for unpadded numbers. Also double-check the extension: it only scans txt or md.
    • "It restarted from the top." That's wrap_around, or you reloaded the workflow - state is tracked per configuration in memory, keyed on folder+base+format+extension, so it doesn't survive a restart.
    • "It's skipping files." The index is parsed from the filename, so _010 and _10 are different matches to the node. Keep your numbering consistent.
    • Empty folder_path surprise. Leaving it blank is a feature (output dir), but if you think you pointed it somewhere and it's loading output-dir files instead, that's why.

    LoadTextFiles is a small node with a narrow job, and it does that job cleanly. If you've ever wanted to A/B a stack of prompts across a batch and then replay the winner set, this is the least-friction way to do it - write files, load files, walk away.

    Categorynhk/text

    Inputs (8)

    NameTypeDefaultDescription
    folder_pathSTRINGTarget directory to scan for text files
    base_filenameSTRINGsaved_textBase name pattern to match against files
    file_extensionCOMBOtxt2 options: txt, md
    counter_formatSTRING_{counter:03d}Format string for numeric counter pattern
    auto_incrementBOOLEANtrueAutomatically advance to next file on each execution
    set_tooptINT00–9999Set to specific index (0 = continue from last, >0 = jump to that index)
    repeat_countoptINT11–100Load same file this many times before advancing to next
    wrap_aroundoptBOOLEANtrueReturn to first file after reaching the last one

    Outputs (5)

    NameTypeDescription
    text_contentSTRINGβ€”
    loaded_filepathSTRINGβ€”
    available_countINTβ€”
    current_filenameSTRINGβ€”
    repeat_statusSTRINGβ€”