ComfyUI Node

sanmi_EditWildcards

Create and rewrite wildcard files from inside the graph

By 438443467·Created 2 years ago·Updated about a year ago· 27
sanmi_EditWildcards
    • wildcard_name
    wildcard_name
    replacefalse
    replace_text

    Most wildcard nodes read text files. This one writes them. Feed it a wildcard name and some text, and it creates the matching .txt file if it doesn't exist, or overwrites it if you say so - all from inside the workflow, no file manager required. It's the maintenance node for the pack's other wildcard nodes: build or update your option lists as part of the graph instead of editing text files by hand.

    How it works

    Give it a wildcard_name containing a __name__ token (or several). It resolves each to wildcards/name.txt inside the pack's folder. If the file doesn't exist, it creates it and writes replace_text into it. If the file exists and you've set the replace toggle to true, it overwrites the contents with replace_text. If replace is false and the file exists, it leaves it alone. The node returns the wildcard_name string unchanged as its output - so you can chain it in front of a consuming wildcard node without disturbing the text flow.

    Inputs and outputs

    • wildcard_name - the __name__ token(s) whose files you want to create or edit.
    • replace - BOOLEAN; false = only create if missing, true = always overwrite.
    • replace_text - the multiline text to write into the file.

    Output: wildcard_name (STRING) - a pass-through of the input, so it slots into a chain.

    What it's actually for

    Say you're generating outfit prompts with ClothingWildcards or SimpleWildcards, and the list of outfits needs refreshing. Instead of opening wildcards/outfit.txt in a text editor, you drop this node in front with the new list in replace_text, run once with replace on, then either keep it (it'll just re-write the same list) or bypass it. It's file management masquerading as a node - which is either convenient or a footgun, depending on how you feel about a graph silently rewriting files on your disk.

    Watch out for

    This node writes files with no confirmation, in the pack's wildcards/ folder. If you point replace at a token whose file holds a curated list you care about, one run overwrites it. There's no backup. Also, since the April 2025 rewrite stripped every "Sanmi Simple Node" from the repo, a fresh install won't have this node (or even the wildcards/ directory) - you'd pull it from the older Load_Image_Batch.py in git history. If all you need is reading wildcards, SimpleWildcards is the one you actually use day to day.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/438443467/ComfyUI-GPT4V-Image-Captioner
    

    Restart ComfyUI. No models, no extra dependencies.

    CategorySanmi Simple Nodes/Simple NODE

    Inputs (3)

    NameTypeDefaultDescription
    wildcard_nameSTRING
    replaceBOOLEANfalse
    replace_textSTRING

    Outputs (1)

    NameTypeDescription
    wildcard_nameSTRING