Nodes/MD Nodes/MD: Smart Filename Builder
ComfyUI Node

MD: Smart Filename Builder

Filenames that tell you what the render actually was

By MDMAchine·Created about a year ago·Updated 3 months ago· 15
MD: Smart Filename Builder
    • full_path_prefix
    • filename_preview
    presetCustom
    base_templateMD_Nodes_Workflow %Y-%m-%d
    project_pathAce-Step/313/
    mode_tag(Custom Mode)
    steps0
    schedule_info
    seed0
    genre
    custom_tag_1
    custom_tag_2
    counter_start0
    include_stepstrue
    include_scheduletrue
    include_seedfalse
    include_genrefalse
    include_countertrue
    separator -
    genre_max_length40
    debug_mode0 - Silent
    enable_profilingfalse

    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; the mode_tag input 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.

    CategoryMD_Nodes/Utility

    Inputs (20)

    NameTypeDefaultDescription
    presetCOMBOCustomFILENAME 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_templateSTRINGMD_Nodes_Workflow %Y-%m-%dBASE 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_pathSTRINGAce-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_tagoptSTRING(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.
    stepsoptINT0SAMPLING STEPS • Purpose: Appends step count (e.g., '20S').
    schedule_infooptSTRINGSCHEDULER INFO • Purpose: Appends scheduler name/sigma info.
    seedoptINT00–9007199254740991SEED VALUE • Purpose: Appends JS-safe seed (e.g., 'Seed_12345').
    genreoptSTRINGGENRE TAGS • Purpose: Appends sanitized genre string.
    custom_tag_1optSTRINGCUSTOM TAG 1 • Purpose: Extra user-defined tag (auto-sanitized).
    custom_tag_2optSTRINGCUSTOM TAG 2 • Purpose: Extra user-defined tag (auto-sanitized).
    counter_startoptINT00–99999COUNTER VALUE • Purpose: Current index for numbering (e.g. #0001). • Usage: Connect FilenameCounterNode here.
    include_stepsoptBOOLEANtrueINCLUDE STEPS • Toggle appending step count.
    include_scheduleoptBOOLEANtrueINCLUDE SCHEDULE • Toggle appending scheduler info.
    include_seedoptBOOLEANfalseINCLUDE SEED • Toggle appending seed value.
    include_genreoptBOOLEANfalseINCLUDE GENRE • Toggle appending genre tags.
    include_counteroptBOOLEANtrueINCLUDE COUNTER • Toggle appending numbered index.
    separatoroptSTRING - SEPARATOR • Purpose: String used to join filename parts. • Options: ' - ', '_', ' ', etc. ⭐ Recommended: ' - ' is most readable.
    genre_max_lengthoptINT4010–100GENRE MAX LENGTH • Purpose: Truncate long genre strings to keep filenames manageable.
    debug_modeoptCOMBO0 - SilentLOGGING VERBOSITY • Controls console output and string parse profiling.
    enable_profilingoptBOOLEANfalseENABLE PROFILING • Auto-on if debug >= 1.

    Outputs (2)

    NameTypeDescription
    full_path_prefixSTRING
    filename_previewSTRING