BD Filename Template
Stop building filenames with string-concat spaghetti — resolve %var% templates in one node
- filename
- status
Every serious ComfyUI user has a workflow that looks like four Text Concatenate nodes chained into a filename, with a separator you constantly forget. This node kills that. BD_FilenameTemplate takes one template string with %variable% placeholders, fills in the values you give it, and emits a single resolved STRING you wire straight into any save node's filename input.
It's the standalone, no-side-effect half of ComfyUI-BrainDead's save-context system: the BD Save Context node handles the persistent path templates for the pack's own save nodes, while this one is the lightweight resolver you can use anywhere - including ComfyUI's built-in SaveImage. Same templating, no context to register, no files touched.
How it works
You write a template, it substitutes variables. Forward slashes become subdirectories; empty variables collapse cleanly (so characters/%name%/%name%_v%version%%suffix% with an empty name doesn't leave you with //); undefined variables stay in the output as literal %var% text so typos surface instead of silently corrupting your file paths.
The built-in variables are %character%, %name%, %version%, %project%, %tag%, and %suffix% - the naming vocabulary the whole pack uses. Anything else goes in via custom_vars, one key=value per line.
The inputs that matter
- template - the only required one. Default:
characters/%character%/%name%_v%version%%suffix%. - version - just the number, no
vprefix; the template adds thev(default01). - tag / suffix - the pack's convention:
tagis a part name likefaceortopwear,suffixis a trailing bit like_albedoor_v2. - custom_vars - multiline
key=valueextras, e.g.subfolder=PBRorresolution=4096. - strict - when true, raises an error if the template references a variable you never defined. Great for catching a typo'd
%sufix%in a template you're shipping to a team.
Outputs are filename (the resolved STRING) and status (a text log of what resolved and whether anything was left undefined).
What it looks like
template: characters/%character%/%name%_v%version%%suffix%
character: letti
name: topwear
version: 03
suffix: _albedo
→ characters/letti/topwear_v03_albedo
Wire filename into any save node's filename/filename_prefix input and you're done.
Install
It's part of the BrainDead pack - install that once and this node (plus ~110 siblings) appears under 🧠BrainDead/Prompt:
cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt
Or search "BrainDead" in ComfyUI Manager and restart. This node has zero extra dependencies - pure string work. Note the pack is written against ComfyUI's V3 extension API, so a reasonably current ComfyUI matters more than anything else here.
Troubleshooting
%suffix%came out as literal text - you misspelled a variable or never set it. Either fill it in or setstrictto catch it.- A save landed in the wrong folder - check the trailing slashes in your template;
%character%/with an empty character collapses to a leading slash that resolves to your output root. - You want a file naming, not a folder structure - just don't put slashes in the template.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | characters/%character%/%name%_v%version%%suffix% | Template with %varname% placeholders. Forward slashes create subdirectories. Undefined variables stay as %name% in output unless strict=True. |
| characteropt | STRING | — | |
| nameopt | STRING | — | |
| versionopt | STRING | 01 | Version string. Just the number/code, no 'v' prefix (template adds it). |
| projectopt | STRING | — | |
| tagopt | STRING | Generic tag — typical use: part name like 'face', 'topwear', 'arm-l'. | |
| suffixopt | STRING | Trailing suffix — typical use: '_albedo', '_normal', '_v2'. | |
| custom_varsopt | STRING | Additional variables, one per line as key=value. Examples: layer=topwear pass=normal resolution=4096 These become %layer%, %pass%, %resolution% in the template. | |
| strictopt | BOOLEAN | false | If True, raise an error when the template contains undefined %variables%. If False, leave them in the output as %varname% literals. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| filename | STRING | — |
| status | STRING | — |