🍒Prompt_Loader📝提示词加载器
Batch-generate from a folder of .txt prompts, one at a time or all at once
- prompt_list
- file_names
- current_index
Prompt_Loader turns a folder of plain .txt files into prompts for your workflow, with two very different modes: dump the whole folder into a batch, or step through the folder one prompt per run. That second mode is the one people actually get excited about - it's how you set up a "generate one image per prompt, hit Queue and walk away, come back to a folder full of results" loop without writing any custom scripting.
How it works
Point it at a directory and it walks the whole tree (subfolders included) collecting every .txt file, sorts them with natural sorting (so 2.txt sorts before 10.txt, which naive lexicographic sort gets wrong), and reads each one. Non-sequential mode just hands you the whole pile as a list, optionally sliced by start_index and capped by load_cap - feed that into a batch-capable sampler or iterate with a Loop.
Sequential mode is where the design gets interesting. It keeps an in-memory counter per node instance (keyed by the node's unique ID plus the folder path). Bump the seed value and the counter advances to the next file; turn on reset_to_first and it jumps back to start_index. The seed-as-advance-button trick is unusual but genuinely handy - you get a "next prompt" control that's hard to build with stock nodes. There's also a reload toggle: with it on, the node re-checks file hashes (via ComfyUI's IS_CHANGED) so editing a prompt file re-runs the graph automatically; off, it only re-runs when you touch the node's own inputs.
The inputs that matter
- prompt_dir - the folder path. The only field you actually must set.
- sequential_mode - on = one prompt per run, off = whole folder as a list.
- reset_to_first - jump back to the start position.
- start_index - where to begin;
-1means "start at the last file." - load_cap - max prompts per run;
0means no cap. - seed - in sequential mode, changing this is your "next file" button.
- reload - re-run when the prompt files' contents change.
Three outputs: prompt_list (STRING list), file_names (STRING list - the .txt base names, handy for naming saved images), and current_index (INT).
Installation
Part of ComfyUI_KimNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/wjl0313/ComfyUI_KimNodes
Restart ComfyUI. No extra dependencies.
Common issues
Files must be UTF-8 - the node explicitly logs errors for anything else and skips those files, so a stray Windows-1252 prompt is silently dropped. Empty folder or no .txt files returns empty lists and the graph just sits there doing nothing, which is easy to misread as a bug. And the sequential counter lives in memory: restart ComfyUI and it forgets where it was (set start_index to recover). One more quirk - sequential mode ignores load_cap by design, and it only reads the first non-empty text per file, so multi-prompt-per-file setups need a different tool. Otherwise: reliable, thoughtful, and the rare node that makes batch prompt work feel like a feature instead of a hack.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt_dir | STRING | — | |
| sequential_mode | BOOLEAN | false | — |
| reset_to_first | BOOLEAN | false | — |
| start_index | INT | 0-1–18446744073709550000 | 设置从第几个提示词开始加载: -1: 从最后一个开始 0或更大: 从指定序号开始 |
| load_cap | INT | 0 | 设置每次加载的提示词数量: 0: 加载全部 1或更大: 加载指定数量 |
| seed | INT | 6660–18446744073709550000 | — |
| reloadopt | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| prompt_list | STRING | — |
| file_names | STRING | — |
| current_index | INT | — |