Nodes/Orel's Nodes/Filename Builder
ComfyUI Node

Filename Builder

Stop naming 400 outputs ComfyUI_00042

By DarkOrel·Created about a month ago·Updated 22 days ago· 1
Filename Builder
  • lora_name
  • prompt_preset
  • seed
  • face_score
  • suffix
  • filename
◄include_seedtrue►
◄include_scoretrue►
◄include_prompttrue►
◄include_suffixtrue►
◄separator_►

ComfyUI's SaveImage will happily write ComfyUI_00391_.png forever. The metadata inside that file is a perfect record of how it was made. The filename tells you nothing, and if you're batching LoRA tests or QC runs, "nothing" gets painful fast.

Filename Builder assembles a descriptive filename stem out of the values that actually vary between runs - LoRA, prompt preset, seed, score, whatever suffix you want - and sanitises the result so it survives Windows.

What it assembles, in order

Parts get joined with your separator, and each one only appears if its toggle is on and there's a value for it:

  1. the LoRA basename (directory and extension stripped)
  2. the prompt preset text
  3. seed<value>
  4. score<value>
  5. your suffix

So a typical run gives you something like klein_softskin_editorial_closeup_seed8842190_score59.9_v3. If every field is empty, you get output rather than an empty string - a small courtesy that keeps SaveImage from writing files named _00001_.png.

Note the % handling on the score: a value of 59.9% becomes score59.9. Which is nice, because the face-similarity percentage from this pack's QC nodes drops straight in.

Inputs and outputs

  • include_seed, include_score, include_prompt, include_suffix (BOOLEAN, all default true) - per-field toggles.
  • separator (STRING, default _) - any character or short string; separators containing slashes are replaced with _.
  • lora_name, prompt_preset, seed, face_score, suffix (optional, type *) - the wildcard means INT, FLOAT and STRING all connect without converters in front.
  • filename (STRING) - the stem.

It does not write a file. It produces a string, and you wire that into SaveImage's filename_prefix.

What the sanitising actually does

Cross-platform filename handling is one of those chores nobody does properly, so here's what's real:

  • Characters illegal on Windows get replaced with _: < > : " / \ | ? * plus control characters.
  • A value containing slashes is flattened to its last segment - paste a full model path in and you get the filename, not a directory tree.
  • .. and . sanitise to nothing, so a value can't walk out of your output folder.
  • Windows reserved device names (CON, PRN, AUX, NUL, COM1–COM9, LPT1–LPT9) get an underscore prefixed.
  • Leading and trailing spaces and dots are stripped.
  • Capped at 180 characters, trimmed at a clean boundary.

That adds up to a filename that survives a Windows filesystem, a cloud-sync client, and a Linux box that's just copying it around. Boring, correct, worth knowing.

Wiring it up

LoRA Loader + Name → LORA_BASENAME → lora_name
Prompt Template → prompt (or a short preset string) → prompt_preset
KSampler → seed → seed
Face Similarity → percentage → face_score
                          filename → SaveImage.filename_prefix

Core ComfyUI's filename_prefix has its own templating - %date:yyyy-MM-dd%, %NodeName.widget% - and it's fine for dates and widths. What it doesn't do is join five heterogeneous values into one sanitised stem, which is the gap this fills.

One perspective worth keeping: filenames are cosmetic. The real reproducibility record is the workflow chunk embedded in the PNG. A good filename saves you from opening forty files to find one. It is not a backup of your settings.

Install

Manager → search Orel's Nodes → Install → restart → hard-refresh the browser.

cd ComfyUI/custom_nodes
git clone https://github.com/DarkOrel/Orels-Nodes.git orels-nodes
python -m pip install -r orels-nodes/requirements.txt

Restart and hard-refresh. This node needs nothing from the requirements file; it imports folder_paths from ComfyUI and uses the standard library otherwise.

Gotchas

Long prompts make terrible filenames. A 200-character prompt will eat the whole 180-character budget and push the seed out the end. Keep the prompt_preset input short and deliberate - this is a preset, not your prompt.

Toggles and values are separate conditions. A seed that's empty is skipped even with include_seed on, so a run where the seed never got wired silently loses that segment instead of producing seed.

Collisions are on you. Two runs of the same LoRA with the same prompt and the same seed produce the same name. SaveImage appends its own counter, so you won't overwrite - you'll just get run_00001_.png and run_00002_.png side by side, which is fine, but it means the filename alone won't uniquely identify a file you later move elsewhere.

CategoryOrel's Nodes/File

Inputs (10)

NameTypeDefaultDescription
include_seedBOOLEANtrue—
include_scoreBOOLEANtrue—
include_promptBOOLEANtrue—
include_suffixBOOLEANtrue—
separatorSTRING_—
lora_nameopt*—
prompt_presetopt*—
seedopt*—
face_scoreopt*—
suffixopt*—

Outputs (1)

NameTypeDescription
filenameSTRING—