Nodes/ComfyUI_BishaNodes/Wildcard Replace (with values from File)
ComfyUI Node

Wildcard Replace (with values from File)

The wildcard node that reads its values from disk

By vladpro3·Created about a year ago·Updated 5 months ago· 0
Wildcard Replace (with values from File)
    • prompts
    prompt
    wildcard
    file_path
    next_linefixed
    start_line0
    values_count1
    value_separator,
    prepend_text
    append_text

    This is the "wildcard from a file" version of the pack's prompt template trick. Where plain Wildcard Replace expects your candidate values to arrive as an input list, WildcardReplaceFromFile pulls them straight out of a .txt file - one candidate per line - and swaps them into a {placeholder} in your prompt. Same swap logic, different source of values, and that difference is exactly why you'd pick it: your value pool already lives on disk, so why route it through another node?

    The picture is: you have a template prompt containing a literal token, a file of names or styles or objects, and you want one finished prompt per run. Set prompt to a portrait of {person} in the rain, set wildcard to {person}, point file_path at your names file, and out comes a portrait of Alice in the rain - with Alice chosen by the next_line mode. increment walks the file forward run by run, decrement backward, fixed parks on the line set by start_line, and random jumps around, re-rolling every queue because the node marks itself always-changed rather than cacheable.

    The inputs that matter:

    • prompt - your template, containing the token you set in wildcard.
    • wildcard - the literal string to replace (e.g. {person}).
    • file_path - path to a .txt file, one value per line; supports $ENV_VAR expansion. Blank lines are skipped.
    • values_count - how many lines to pull; joined into the replacement with value_separator (default ,).
    • next_line / start_line - the line-picking controls.

    One output: prompts, a single STRING - note, this is the one prompt node in the pack that takes one prompt and returns one prompt, not a list. If you want to push a whole batch of templates through at once, that's Create Prompts With Text From File's job; this node is the single-shot wildcard. If values_count exceeds the file length in increment/decrement mode, it clamps to what's on disk, so no silent repeats mid-run.

    The gotchas are shared with its siblings. A non-empty file_path that points at nothing raises FileNotFoundError - annoying but at least explicit. A genuinely empty path returns empty lines, and with no candidates the token just doesn't get replaced. And the swap is literal and case-sensitive: {person} won't match { Person }, and if the token isn't in your prompt at all, the prompt sails through untouched.

    Install the pack once and you've got all three prompt nodes. Custom Nodes Manager → search ComfyUI_BishaNodes → install → restart, or from your ComfyUI folder:

    cd ComfyUI/custom_nodes
    git clone https://github.com/vladpro3/ComfyUI_BishaNodes.git
    

    No models to fetch, no dependencies to install, MIT-licensed. It's a small node with a small job - if you already keep your value lists as text files, this is the least-friction way to make a wildcard system without adopting a whole dynamic-prompt framework.

    CategoryBishaNodes/prompt

    Inputs (9)

    NameTypeDefaultDescription
    promptSTRING
    wildcardSTRING
    file_pathSTRING
    next_lineCOMBOfixed4 options: increment, decrement, random, fixed
    start_lineINT0
    values_countINT1
    value_separatorSTRING,
    prepend_textoptSTRING
    append_textoptSTRING

    Outputs (1)

    NameTypeDescription
    promptsSTRING