Nodes/ComfyUI-Prompt-Preset-Selector/Prompt Preset Selector (Folder, Wildcard)
ComfyUI Node

Prompt Preset Selector (Folder, Wildcard)

Point this at a folder of prompt files and stop merging by hand

By shin131002·Created 8 months ago·Updated 2 days ago· 2
Prompt Preset Selector (Folder, Wildcard)
    • text
    • preset_list
    • selected_info
    folder_path
    exclude_pattern
    keyword
    keyword_modeOFF
    selection_modeManual
    preset_index0
    seed0
    enable_wildcardtrue

    There's a moment in every ComfyUI prompt library's life where it outgrows single files. You start with one styles.txt, then camera angles, then lighting, then a character list with subfolders and backups - and the "one file, one dropdown" preset nodes start to hurt. The Folder version of Prompt Preset Selector is the fix: point it at any folder on disk, and it recursively swallows every .txt, .yaml, and .yml under it, tags each line with its path so nothing collides, and layers the usual filters and wildcards on top. It's a text-plumbing node, not a model thing - no downloads, no API keys, nothing touches the GPU. It just quietly does the boring, error-prone job of assembling a prompt pool for you.

    How it works

    On every run the node walks folder_path with a recursive glob, so subfolders count - a real upgrade over the single-file selector. Every line gets prefixed with the path relative to your folder, so colors.txt: red and sub/colors.txt: crimson stay distinct instead of fighting for the same spot. Files load in alphabetical order of relative path, which keeps preset_index stable between runs as long as your folder doesn't change. And because files are reloaded fresh each execution, editing a preset mid-batch just works - no restart, no refresh ritual.

    Full wildcard syntax is on board: {red|blue|green} choices (nestable), __filename__ to pull a random line from another file, and {__key__|__key__} to reference YAML keys - including keys in other files, since the folder pool is treated as one merged set.

    The inputs that matter

    Most of these are shared across the whole pack, so learn them once:

    • folder_path - the one that does all the work. Any absolute path, subfolders included.
    • exclude_pattern - comma- or newline-separated glob patterns for skipping backups and drafts.
    • keyword + keyword_mode - filter the pool. OFF uses everything, AND requires all keywords, OR matches any. Exclude with a minus: front -wide means "has front, not wide" (and it's -wide, no space after the dash).
    • selection_mode - Manual (driven by preset_index), Sequential, Sequential (continue), or Random (seeded, so reproducible).
    • enable_wildcard - default true, and it should stay there unless you want {A|B|C} to come out as literal text.

    Three outputs: text (the winner - wire it into your positive or negative prompt), preset_list (a numbered list so you can find the index you want), and selected_info (a log line saying what got picked and why). If nothing matches, text is an empty string - deliberately, not an error - and selected_info explains itself. That's the first output to check when a batch comes back blank.

    Install

    ComfyUI Manager has it under "Prompt Preset Selector", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/shin131002/ComfyUI-Prompt-Preset-Selector.git
    # only needed for YAML files, and usually already installed:
    pip install pyyaml
    

    Then restart ComfyUI. That's the whole install - no model files, no heavy dependencies. PyYAML is the only extra and the node just warns if it's missing. It'll also happily read from Impact Pack's wildcards/ folder if you have that installed.

    Where people get burned

    Three traps, all documented in the README and all worth internalizing:

    1. * crosses /. Because exclude patterns use Python's fnmatch, *.txt excludes files in subfolders too - unlike a shell glob where * stops at a directory separator. There's currently no clean way to exclude only the top-level .txt files.
    2. Exclude also matches the bare file name. a.txt catches sub/a.txt as well. To kill just the subfolder copy, write the full relative path: sub/a.txt.
    3. Indices shift. preset_index numbers the filtered list, so changing the keyword, or dropping a file into the folder, renumbers everything. Scope with a keyword prefix like colors.txt: to pin results to one file.

    Sequential (continue) also forgets its position the moment you reload the workflow - it only persists during a live session. And before you build a big library on it: the author ships with an explicit "no individual support" disclaimer (it's MIT, so forking is the intended fix). It's a genuinely handy utility - just don't expect a helpdesk.

    Categorytext

    Inputs (8)

    NameTypeDefaultDescription
    folder_pathSTRING
    exclude_patternSTRING
    keywordSTRING
    keyword_modeCOMBOOFF3 options: OFF, AND, OR
    selection_modeCOMBOManual4 options: Manual, Sequential, Sequential (continue), Random
    preset_indexINT00–9999
    seedINT00–18446744073709550000
    enable_wildcardBOOLEANtrue

    Outputs (3)

    NameTypeDescription
    textSTRING
    preset_listSTRING
    selected_infoSTRING