TXT Batch Loader
Feed a per-image prompt file for every image in your batch
- content
- filename
People have been asking how to process a folder of images where each image gets its own prompt since ComfyUI was young - it's one of the oldest recurring requests in the community. TXT Batch Loader is the clean answer to that exact workflow: it reads a folder of text files, hands you one file's contents per queue run, and advances to the next file every execution. Wire its content output into your positive prompt, pair it with Image Batch Loader walking the matching images, and each queue run generates image #1 with prompt #1, image #2 with prompt #2, and so on. That single pattern is why this node exists.
It's part of Zar4X/ComfyUI-Batch-Process, and it shares the loader DNA of its siblings: same directory-scan caching, same natural sort, same 1-based index range slicing, same reset_on_queue loop control.
How it works
directory points at a folder of .txt files. The node reads them in, and on each execution returns the next file's text through content and its name through filename (extension stripped). Modes are single_text, incremental_text, and random (seeded), and - same as the image loader - single and incremental both advance through the list in the current code, so don't lose sleep over the distinction.
The inputs that matter
directory- required path to the text folder.search_title+filename_option- filter which files count, exactly like the Image Batch Loader: match against the whole name, prefix, suffix, both, or neither. Only applies whensearch_titleis non-empty.search_content- this one's the party trick: it filters files by what's inside them. It's a case-insensitive literal substring match, not regex, sosearch_content: "cat"keeps only the prompt files that mention "cat". Great for splitting a prompt folder by topic.start_index/end_index- 1-based range selection if you only want files 5–20.reset_on_queue- leave it alone during a batch run; flip it 0→1 to restart from the first file.
Two outputs: content (the full text of the file, UTF-8) and filename. Both feed wherever they need to go - content into a CLIP Text Encode or a saver's contents, filename into a prefix.
Installing it
Same as the rest of the pack. In ComfyUI Manager search ComfyUI-Batch-Process, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Zar4X/ComfyUI-Batch-Process
Restart ComfyUI. No models, no extra deps beyond what ComfyUI already ships.
Where people get burned
Same empty-folder trap as its image sibling: no matching files means no exception, so check the console for "No matching txt files found" and verify your path and filters before blaming your prompt. Also remember the wrap-around - incremental mode cycles back to the first file once the queue passes the end, which is usually what you want for a long-running loop but will look like a bug the first time you see it. One more: the content filter is case-insensitive and literal, so if you're used to regex-flavored search you'll be surprised it can't do ^(cat|dog)$. That's by design - keep it simple.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| search_title | STRING | — | |
| search_content | STRING | — | |
| delimiter | STRING | — | |
| mode | COMBO | incremental_text | 3 options: single_text, incremental_text, random |
| seed | INT | 00–18446744073709550000 | — |
| filename_option | COMBO | 5 options: filename, prefix, suffix, prefix & suffix, prefix nor suffix | |
| start_index | INT | 00–999999 | Start index (1-based). Use 0 to start from beginning, or set 1 for first text file, 2 for second text file, etc. |
| end_index | INT | 00–999999 | End index (inclusive, 1-based). Use 0 to include all remaining text files, or set >0 to limit range (1=first, 2=second, etc.). |
| reset_on_queueopt | INT | 10–1 | Any change to this value (0↔1) resets the read index to start from the first file again. Keep unchanged during a queue run to advance normally. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| content | STRING | — |
| filename | STRING | — |