Load Random File From Path By Prefix
Your prompt library, with a randomizer on it
- text
- file_name
- file_path
- folder_path
- status
If you keep prompts as text files - and serious batch explorers do - you eventually want to pull one at random. Load Random File From Path By Prefix is that, with a filter: point it at a folder, give it a filename prefix and extension, and it picks a random matching file and hands you its contents plus its path. The default prefix, prompt_wan22_, tells the story - it's built for keeping prompts organized by model/task (prompt_wan22_01.md, prompt_wan22_02.md…) and sampling them for variation.
The prefix filter is the feature that makes this different from "random file in folder." It lets one workflow hold several prompt collections side by side - one prefix per style, per model, per project - and sample within a coherent group instead of across everything you've ever written.
How it works
Scan the folder for files matching prefix + extension (default .md). recursive (off by default) decides whether to descend into subfolders; case_sensitive (off) decides whether the prefix match cares about capitalization. Then the selection:
seed- default -1 = true random. Set a positive seed to make the pick reproducible.index_override- default -1; set a specific index to force a particular file. Handy for checking "what would the third match have been" or pinning a favorite.
Outputs:
text- the file's contents, ready to wire into a text encoder or prompt assembler.file_name,file_path,folder_path- where it came from.status- a string reporting success or failure.
The status output is the graceful-degradation contract this pack leans on: if no file matches the prefix, you get a status message instead of a red crash bubble, and your queue survives. debug_mode (optional) prints the scan details when you're hunting a mismatch.
Installing it
Part of CorvaeOboro's ComfyUI_illumorae (CC0, pure code). ComfyUI Manager → search illumorae, or:
cd ComfyUI/custom_nodes
git clone https://github.com/CorvaeOboro/ComfyUI_illumorae
Common issues
- Nothing ever loads - check
prefixagainst your actual filenames. If your files arewan22_prompt_01.mdbut the prefix saysprompt_wan22_, no match. Also confirmextensionincludes the dot (.md, notmd) and thatrecursivematches where your files actually live. - Same file every time - seed -1 should randomize; if you're seeing repeats, remember the ComfyUI cache and rerun behavior - the node needs to re-roll. Set a fresh seed if a specific reproducible pick is what you actually want.
- Prompt text looks mangled - it returns raw file contents; if your files have markdown headers or metadata lines, they'll flow into the text output. Keep prompt files clean if you're wiring
textstraight into a CLIP encode.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| folder | STRING | C:/prompts | — |
| prefix | STRING | prompt_wan22_ | — |
| extension | STRING | .md | — |
| recursive | BOOLEAN | false | — |
| case_sensitive | BOOLEAN | false | — |
| seed | INT | -1 | — |
| index_override | INT | -1 | — |
| debug_modeopt | BOOLEAN | false | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| file_name | STRING | — |
| file_path | STRING | — |
| folder_path | STRING | — |
| status | STRING | — |