Nodes/BrainDead Nodes/BD Filename Template
ComfyUI Node

BD Filename Template

Stop building filenames with string-concat spaghetti — resolve %var% templates in one node

By BizaNator·Created 8 months ago·Updated 3 days ago· 15
BD Filename Template
    • filename
    • status
    templatecharacters/%character%/%name%_v%version%%suffix%
    character
    name
    version01
    project
    tag
    suffix
    custom_vars
    strictfalse

    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 v prefix; the template adds the v (default 01).
    • tag / suffix - the pack's convention: tag is a part name like face or topwear, suffix is a trailing bit like _albedo or _v2.
    • custom_vars - multiline key=value extras, e.g. subfolder=PBR or resolution=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 set strict to 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.
    Category🧠BrainDead/Prompt

    Inputs (9)

    NameTypeDefaultDescription
    templateSTRINGcharacters/%character%/%name%_v%version%%suffix%Template with %varname% placeholders. Forward slashes create subdirectories. Undefined variables stay as %name% in output unless strict=True.
    characteroptSTRING
    nameoptSTRING
    versionoptSTRING01Version string. Just the number/code, no 'v' prefix (template adds it).
    projectoptSTRING
    tagoptSTRINGGeneric tag — typical use: part name like 'face', 'topwear', 'arm-l'.
    suffixoptSTRINGTrailing suffix — typical use: '_albedo', '_normal', '_v2'.
    custom_varsoptSTRINGAdditional variables, one per line as key=value. Examples: layer=topwear pass=normal resolution=4096 These become %layer%, %pass%, %resolution% in the template.
    strictoptBOOLEANfalseIf True, raise an error when the template contains undefined %variables%. If False, leave them in the output as %varname% literals.

    Outputs (2)

    NameTypeDescription
    filenameSTRING
    statusSTRING