Nodes/ComfyUI illumorae/Load Random File From Path By Prefix
ComfyUI Node

Load Random File From Path By Prefix

Your prompt library, with a randomizer on it

By CorvaeOboro·Created 8 months ago·Updated 6 days ago· 1
Load Random File From Path By Prefix
    • text
    • file_name
    • file_path
    • folder_path
    • status
    folderC:/prompts
    prefixprompt_wan22_
    extension.md
    recursivefalse
    case_sensitivefalse
    seed-1
    index_override-1
    debug_modefalse

    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 prefix against your actual filenames. If your files are wan22_prompt_01.md but the prefix says prompt_wan22_, no match. Also confirm extension includes the dot (.md, not md) and that recursive matches 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 text straight into a CLIP encode.
    Categoryillumorae

    Inputs (8)

    NameTypeDefaultDescription
    folderSTRINGC:/prompts
    prefixSTRINGprompt_wan22_
    extensionSTRING.md
    recursiveBOOLEANfalse
    case_sensitiveBOOLEANfalse
    seedINT-1
    index_overrideINT-1
    debug_modeoptBOOLEANfalse

    Outputs (5)

    NameTypeDescription
    textSTRING
    file_nameSTRING
    file_pathSTRING
    folder_pathSTRING
    statusSTRING