Text File Line Loader
Iterate Through a Prompt File One Line at a Time
- line_text
- line_count
You have a text file of 50 prompts, one per line, and you want each queue run to grab the next one. If you've tried to script that yourself you know the pain: ComfyUI doesn't carry state, so "next line" is genuinely hard to express. Text File Line Loader does exactly that, and it's the node you want when you're batch-generating from a prompt list, a config file, or a dataset manifest.
It's the utility twin of the pack's Number Counter - same "remember where I left off" energy, aimed at text instead of integers. Wire its line_text into your positive prompt (via a text-concat node) and each run walks down the file automatically.
How it works
Point file_path at a text file. Two modes, and they behave very differently:
automatic- the node keeps a persistent "next line" pointer keyed bylabel(default"TextBatch"). Each run returns the current line, then advances. When it reaches the end it wraps back to the top. This is the iterate-through-the-file mode.index- grab the line at a fixedindex(0-based). No state, deterministic, and the file is re-read and re-hashed each run so edits bust the cache automatically. Perfect when the index comes from a counter node rather than from time.
The label field is the quiet gotcha. The automatic mode stores its pointer in a small persisted store under whatever label you gave - two nodes with the same label share a pointer and will fight over the next line. Give every iterator its own label, and use a fresh label if you want to start the file over.
The IS_CHANGED behavior is the smart part: in index mode the node hashes the file contents so an edit to the file triggers a re-run; in automatic mode it always re-runs so the pointer actually advances. Both work as intended - just know that an always-dirty node sits outside ComfyUI's cache, so keep it off the critical path of giant graphs.
Outputs are line_text (the line, stripped of whitespace) and line_count (total non-empty lines - handy for computing "how many prompts until this finishes" or feeding a stop condition). Blank lines are skipped when counting, so the file is really a list of prompts, not raw text.
Install
Search "Trent Nodes" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt
Nothing model-related here - just the pack's base Python deps. Restart ComfyUI after installing. (ComfyUI Manager has been flaky on this pack per the author, tracing to an early repo rename; if it errors, clone manually.)
Common issues
- Two nodes, same label, skipping lines. Your iterators share a pointer. Change the
labelon one. - "It stopped advancing." If
modeis onindex, it never advances - that's the point. Switch toautomatic. - Missing file returns empty. A nonexistent
file_pathyields("", 0)rather than a loud error. Check the console, which logs it. - Want to restart the list? Change the
labelor the file path; both reset the pointer.
For prompt-list batch runs, this is the reliable little workhorse. Pair it with the pack's Number Counter to drive a companion index, or leave it in automatic and just let the file be your loop.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| label | STRING | TextBatch | — |
| mode | COMBO | 2 options: automatic, index | |
| index | INT | 0 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| line_text | STRING | — |
| line_count | INT | — |