π Load Text Files (nhk)
Cycle through saved text files like a prompt jukebox
- text_content
- loaded_filepath
- available_count
- current_filename
- repeat_status
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 scanstxtormd. - "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
_010and_10are 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.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | Target directory to scan for text files | |
| base_filename | STRING | saved_text | Base name pattern to match against files |
| file_extension | COMBO | txt | 2 options: txt, md |
| counter_format | STRING | _{counter:03d} | Format string for numeric counter pattern |
| auto_increment | BOOLEAN | true | Automatically advance to next file on each execution |
| set_toopt | INT | 00β9999 | Set to specific index (0 = continue from last, >0 = jump to that index) |
| repeat_countopt | INT | 11β100 | Load same file this many times before advancing to next |
| wrap_aroundopt | BOOLEAN | true | Return to first file after reaching the last one |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| text_content | STRING | β |
| loaded_filepath | STRING | β |
| available_count | INT | β |
| current_filename | STRING | β |
| repeat_status | STRING | β |