Load Text Directory
One txt file per prompt, a whole folder of them, zero graph rebuilding
- text
- filename_text
If you've ever run a prompt-to-prompt batch by hand - pasting a new prompt into a text node, queueing, repeating for forty prompts - LoadTextDirectory is the node that retires that habit. Point it at a folder of .txt or .md files and it feeds each one into your graph as the text input, one queue per file. It's the text cousin of the pack's batch-video loaders, and it slots straight into CLIP Text Encode or any prompt-processing node.
The workflow pattern is the classic ComfyUI batch trick from the ecosystem docs: keep the graph fixed, vary the input. Combined with PromptSwap or PromptCleaner downstream, you get a whole prompt-engineering pipeline that runs unattended.
How it works
Simple and honest under the hood. It globs the path for files matching pattern (default *, so anything), filters to .txt/.md, sorts the list alphabetically, then reads the file at index. No caching, no special encoding - just a folder walk and a file read.
The three modes decide which file you get:
- single_file - always the file at
index. Deterministic: sort the folder, pick number N. - incremental_file - also walks by
index; handy for driving a "next prompt" loop. - random - picks a file seeded by the
seedinput, so the same seed gives the same prompt. This is the one you want for reproducible random prompt exploration.
The inputs that matter
- path - the only one that will bite you. It's a required string with an empty default, and the node hard-errors with "Path does not exist" if you run it without filling it. Give it an absolute path like
D:\prompts\batch01or/home/you/prompts/batch01. - mode - single_file, incremental_file, or random, as above.
- index - which file (or which step, in incremental). Starts at 0.
- pattern - default
*catches everything. Set*.txtif you keep stray markdown notes in the same folder. - seed - only consulted in random mode.
- label - purely cosmetic, a name for the batch shown in the node. Ignore it.
Outputs: text (the file contents, ready for a text encoder or Show Text) and filename_text (just the filename, no path) - that second one is gold for saving each result with the prompt it was generated from, so you never have to guess which output matched which input.
Installing it
It's part of DJZ-Nodes, Drift Johnson's big grab-bag pack. Manager route: Install Custom Nodes → search DJZ-Nodes → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/DJZ-Nodes
cd DJZ-Nodes
pip install -r requirements.txt
Good news: this node is pure Python stdlib - os and glob only. It doesn't need a single one of the pack's heavier dependencies (opencv, librosa, all of it) to run. You just have to live with the pack's full requirements.txt install if you go the manual route.
Common issues
The empty-path error above is the one people hit, because the default looks harmless. Next most common: you forget that files are matched recursively and your glob catches a .txt in a subfolder you didn't expect - narrow it with pattern. And if you drive this with an index beyond the file count, you get a "No valid text file found" error rather than a graceful wrap; in random mode the seed makes the pick reproducible, so if a batch gives you an uninteresting prompt, that's the seed's doing, not a bug.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | 3 options: single_file, incremental_file, random | |
| seed | INT | 00–18446744073709550000 | — |
| index | INT | 00–150000 | — |
| label | STRING | Text Batch 001 | — |
| path | STRING | — | |
| pattern | STRING | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| filename_text | STRING | — |