BD Get Context Path
Resolve a save context into a filename for ANY save node — even ComfyUI's built-in one
- filename_prefix
- full_path
- directory
- basename
- status
ComfyUI-BrainDead's save-context system is the antidote to filename spaghetti: you define a path template once in BD Save Context - %project%/%character%/%name%_v%version%%suffix% - and every downstream save node resolves against it. The catch: the pack's own save nodes (BD Save File, BD Bulk Save) speak context natively, but ComfyUI's built-in SaveImage and most third-party save nodes don't. BD_GetContextPath is the bridge. It resolves a context's template into a plain STRING you can wire into any save node's filename input.
So: one context node upstream, one GetContextPath per save, and every save in your workflow inherits the same folder structure and naming rules. Change the character once and every output path updates.
How it works
It pulls the template and variables from the registered BD_SaveContext - auto-picking the context if exactly one is registered, or matching by context_id if you have several. Then it resolves the template, including any per-fetch overrides you pass in. It also forces re-execution every Run, so edits to the upstream context are reflected without you touching this node.
One behavior worth knowing: it appends %suffix% to the template if it's not already there, and the suffix input fills it - so a single context can serve many saves, each with its own _albedo / _normal / _head leaf.
The outputs (pick the one that fits your save node)
- filename_prefix - the one you'll use 90% of the time. No extension, no auto-increment; built to feed ComfyUI's SaveImage
filename_prefix, which adds those itself. SaveImage wants the prefix, and this gives you exactly that. - full_path - the complete path including extension and optionally the auto-increment
_NNN, for save nodes that want a finished file path. - directory / basename - the split halves, handy for nodes that take them separately.
- status - diagnostics.
The toggles include_extension / include_increment only affect full_path; filename_prefix never includes either, so you don't accidentally double up with SaveImage's own numbering. filename_override swaps the leaf for this fetch only, and custom_vars layers extra key=value variables on top of the context's (e.g. subfolder=PBR).
Install
Standard BrainDead pack install:
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. Zero extra dependencies - it's pure string resolution.
Troubleshooting
- Status says "no usable context" - you need a
BD_SaveContextregistered upstream. If you have multiple contexts, you must setcontext_idexplicitly; auto-pick only works when there's exactly one. - SaveImage numbers everything 00001 again - right, that's SaveImage's own counter doing its job. You wired
filename_prefix, so the numbering is expected. Usefull_pathwithinclude_incrementif you want the counter baked in instead. - Paths land in the wrong root - check the context's
base_dir; GetContextPath resolves under that.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| context_idopt | STRING | Match a BD_SaveContext id. Empty + exactly one registered = auto-pick. | |
| suffixopt | STRING | Per-fetch suffix → %suffix% in the template (e.g. '_albedo'). | |
| filename_overrideopt | STRING | If set, overrides %name% / %filename% in the template for THIS fetch only. Useful when the context defines a base template but you want a different leaf for this particular save. | |
| include_extensionopt | BOOLEAN | false | When True: full_path includes the extension (.png). filename_prefix never includes extension regardless. |
| extensionopt | STRING | png | Extension used when include_extension=True. PNG by default. |
| include_incrementopt | BOOLEAN | false | When True: full_path includes auto-increment _NNN suffix. filename_prefix never includes increment (let SaveImage handle it). |
| custom_varsopt | STRING | Per-fetch extra variables, one per line as key=value. Layered ON TOP of the context's custom_vars. Examples: subfolder=PBR materials=metal Become %subfolder%, %materials% in the template. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| filename_prefix | STRING | — |
| full_path | STRING | — |
| directory | STRING | — |
| basename | STRING | — |
| status | STRING | — |