Nodes/KRuins-ComfyUI-Node-Suite/KRuins - Wildcard Batch
ComfyUI Node

KRuins - Wildcard Batch

Four Variations, One Queue, and a Receipt for What It Picked

By Rampart187·Created 8 days ago·Updated a day ago· 0
KRuins - Wildcard Batch
  • clip
  • positive
  • negative
  • resolved_prompts
◄promptA photo of a __woman__ with __hair__►
◄negative_prompt►
◄wildcard_folderD:/ComfyUI/ComfyUI/wildcards►
◄batch_size4►
◄seed0►

Wildcards are the cheapest way to get variety out of a model you already like. You write A photo of a __woman__ with __hair__, drop two text files next to your installs, and every image in the batch comes out different. The syntax is old A1111 muscle memory - the bracket form {brown|blonde|black} survives as a trick people rediscover and pass around, and the __file__ form got carried into ComfyUI mostly by Impact Pack, which supplies the same parsing that plenty of workflows use without crediting it.

KRuins - Wildcard Batch is a smaller, opinionated take on the same idea, and its distinguishing feature isn't the wildcards. It's that it builds a batched conditioning tensor - one prompt per image, all in a single queued run - and hands you back a text report of exactly which values were chosen for each image number.

Why the batching matters

The established alternative, DynamicPrompts, works at the queue level: it expands your prompt template into N prompts and queues N separate runs, each with its own seed. That's great for a thousand images and annoying for four - four queue entries, four separate loads, four filenames to correlate back to prompts.

This node does it inside one execution. Feed it clip and a seeded batch_size, and it emits conditioning whose batch dimension equals batch_size, so a single sampler run produces all the variations at once. Fewer moving parts, and the seed is one number instead of N.

The mechanism, briefly

__name__ is matched by a regex allowing letters, digits, underscores, hyphens, and forward slashes (so __colors/pastels__ reads colors/pastels.txt). Files are read UTF-8 with BOM tolerance; blank lines and # comments are skipped. Nested wildcards resolve recursively up to 20 levels deep, with a cycle guard so a file that references itself doesn't hang the run.

Then each of the batch_size prompts gets tokenized and encoded separately. Because prompts have different token counts, the conditionings are zero-padded up to the longest in the batch and concatenated along the batch dimension; pooled outputs are concatenated too when the CLIP provides them. That padding is what makes one tensor out of four uneven prompts.

The RNG is random.Random(seed), so the same seed reproduces the same picks - that's your reproducibility dial, not the sampler seed.

Inputs that matter

clip is required - a CLIP or CLIP-like encoder from your model loader. This node does the text encoding itself, so there's no separate CLIP Text Encode needed.

prompt is your template, and negative_prompt is the negative template (wildcards work there too). wildcard_folder is the full path to your .txt files - and note the default is a hardcoded D:/ComfyUI/ComfyUI/wildcards, somebody's actual machine. Change it or nothing resolves. batch_size goes 1 to 16. seed is the RNG seed.

Outputs: positive → sampler's positive conditioning, negative → negative, resolved_prompts → the text report, which is what you wire into KRuins - Show Text. That pairing is the real workflow: generate four, read the report, know which pick made the good one.

Installing it

Manager → search KRuins ComfyUI Node Suite, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Rampart187/KRuins-ComfyUI-Node-Suite.git

No model download, and nothing to pip install (numpy and Pillow, both already there). The repo does ship a small starter pack of wildcard files, KRuins-free-wilcards.zip, in its root - extract it somewhere permanent and point wildcard_folder at that folder.

Where people get burned

The prompt comes out with literal __hair__ in it. The file wasn't found. The node leaves unresolved tokens as raw text - by design, no crash - and the report says FILE NOT FOUND or EMPTY WILDCARD for that entry. Check the folder path, the .txt extension, and exact filename match. No env vars or ~ expansion here - it's a literal path.

Your picks change when you edit the negative prompt. Subtle, and it's in the source: positives and negatives draw from the same RNG stream, interleaved per image. Change the number of wildcards in the negative and every subsequent positive selection shifts. Not a bug, but it will make you doubt your seed settings.

Batch size doesn't match your latent batch. Set Empty Latent Image's batch_size to the same number. The pack's frontend actually watches for this and warns you on the node, but a mismatch still means prompts and images stop lining up one-to-one.

Max 16 per run. The batch_size widget is bounded there. Need 64? Loop the queue with different seeds, or reach for DynamicPrompts, which was built for big N.

Zero nodes after install. The pack loads a V3-API video module at import time; on an older ComfyUI that import fails and takes all five nodes with it. Console log, then update.

CategoryKRuins

Inputs (6)

NameTypeDefaultDescription
clipCLIP—
promptSTRINGA photo of a __woman__ with __hair__—
negative_promptSTRING—
wildcard_folderSTRINGD:/ComfyUI/ComfyUI/wildcards—
batch_sizeINT41–16—
seedINT00–18446744073709550000—

Outputs (3)

NameTypeDescription
positiveCONDITIONING—
negativeCONDITIONING—
resolved_promptsSTRING—