MD: Smart Filename Builder
Filenames that tell you what the render actually was
- full_path_prefix
- filename_preview
Two weeks after a big batch, every file in your output folder is a mystery: which seed was that, what steps, what genre? SmartFilenameBuilder exists so your filenames answer those questions before you open anything. It builds a structured filename from parts - date, steps, schedule, seed, genre, custom tags, and a counter - sanitizes it, and hands it to your save node as a path prefix. It's a small utility that quietly saves you a lot of "is this the good one?" scrolling.
It's clearly built for audio workflows (the default project_path is Ace-Step/313/ and the presets are Instrumental/Vocal/Master), but it works just as well for images - the parts are generic.
How it works
You give it a base_template (the start of the name, with Python strftime codes - %Y-%m-%d for the date), a project_path (nested subfolders under ComfyUI's output dir, auto-sanitized), and then toggle which optional bits get appended. The node joins the enabled parts with a separator (default " - ") and produces two outputs:
full_path_prefix- the entire path, ready to feed into a Save node's filename field.filename_preview- the final filename as a string, so you can eyeball it or log it.
Everything that goes into the name gets sanitized - the source strips or escapes characters that break filesystems, and it preserves parentheses (useful for mode tags like (Custom Mode)).
The inputs that matter
preset- Custom, Instrumental, Vocal, Master, Raw Output, AB Test. Presets override the manual toggles and pre-set the tags for standard MD workflows. Custom is the one to pick for full control; themode_taginput is only active in Custom mode.base_template+project_path- the skeleton and the folder. Keep the date at the start for OS sorting, as the tooltip suggests.- The include toggles -
include_steps(appends e.g.20S),include_schedule(scheduler/sigma info),include_seed(Seed_12345, JS-safe range),include_genre,include_counter(#0001). - The values -
steps,schedule_info(feed it from a scheduler's info string),seed,genre,custom_tag_1/2,counter_start(wire a counter node here).genre_max_length(default 40) truncates long genre strings.
debug_mode and enable_profiling are the usual console-noise controls.
The honest caveats
It's a string builder, not a saver - you still connect the output to a Save node. And "smart" is doing real work but modest work: it doesn't embed metadata, it just names files well. The presets are audio-flavored; if you're doing images you'll mostly live in Custom mode. The separator default of " - " produces nice names but spaces in filenames can annoy some tooling - switch to _ if that bites you.
Installing
It's part of MD Nodes:
cd path/to/ComfyUI/custom_nodes
git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
cd ComfyUI_MD_Nodes && pip install -r requirements.txt
Or via ComfyUI Manager (search MD Nodes), then restart. Standard pack caveat: the requirements drag in the audio stack and more, even though this node is pure string logic.
If your output folder is chaos, this is a twenty-second fix: date first, steps and seed appended, and suddenly every file is self-describing. That's a quality-of-life win you'll appreciate exactly when you go looking for that one render a month later.
Inputs (20)
| Name | Type | Default | Description |
|---|---|---|---|
| preset | COMBO | Custom | FILENAME PRESET • Purpose: Automatically configure toggles and tags for standard MD workflows. • Options: Custom, Instrumental, Vocal, Master, etc. • Trade-offs: Presets override manual boolean toggles. ⭐ Recommended: 'Custom' for full manual control. |
| base_template | STRING | MD_Nodes_Workflow %Y-%m-%d | BASE TEMPLATE • Purpose: The primary starting text of the filename. • Format: Supports Python strftime codes (%Y=Year, %m=Month, %d=Day). ⭐ Recommended: Keep date at start for easy OS sorting. |
| project_path | STRING | Ace-Step/313/ | PROJECT SUBDIRECTORY • Purpose: Defines nested subfolders within the ComfyUI output directory. • Format: 'Folder/Subfolder/' (Auto-sanitized). ⭐ Recommended: Organize by Project/BPM/Version. |
| mode_tagopt | STRING | (Custom Mode) | MODE TAG (CUSTOM) • Purpose: A text tag identifying the workflow mode. • Requirement: Only active when Preset is set to 'Custom'. • Note: Parentheses are preserved during sanitization. |
| stepsopt | INT | 0 | SAMPLING STEPS • Purpose: Appends step count (e.g., '20S'). |
| schedule_infoopt | STRING | SCHEDULER INFO • Purpose: Appends scheduler name/sigma info. | |
| seedopt | INT | 00–9007199254740991 | SEED VALUE • Purpose: Appends JS-safe seed (e.g., 'Seed_12345'). |
| genreopt | STRING | GENRE TAGS • Purpose: Appends sanitized genre string. | |
| custom_tag_1opt | STRING | CUSTOM TAG 1 • Purpose: Extra user-defined tag (auto-sanitized). | |
| custom_tag_2opt | STRING | CUSTOM TAG 2 • Purpose: Extra user-defined tag (auto-sanitized). | |
| counter_startopt | INT | 00–99999 | COUNTER VALUE • Purpose: Current index for numbering (e.g. #0001). • Usage: Connect FilenameCounterNode here. |
| include_stepsopt | BOOLEAN | true | INCLUDE STEPS • Toggle appending step count. |
| include_scheduleopt | BOOLEAN | true | INCLUDE SCHEDULE • Toggle appending scheduler info. |
| include_seedopt | BOOLEAN | false | INCLUDE SEED • Toggle appending seed value. |
| include_genreopt | BOOLEAN | false | INCLUDE GENRE • Toggle appending genre tags. |
| include_counteropt | BOOLEAN | true | INCLUDE COUNTER • Toggle appending numbered index. |
| separatoropt | STRING | - | SEPARATOR • Purpose: String used to join filename parts. • Options: ' - ', '_', ' ', etc. ⭐ Recommended: ' - ' is most readable. |
| genre_max_lengthopt | INT | 4010–100 | GENRE MAX LENGTH • Purpose: Truncate long genre strings to keep filenames manageable. |
| debug_modeopt | COMBO | 0 - Silent | LOGGING VERBOSITY • Controls console output and string parse profiling. |
| enable_profilingopt | BOOLEAN | false | ENABLE PROFILING • Auto-on if debug >= 1. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| full_path_prefix | STRING | — |
| filename_preview | STRING | — |