Nodes/ComfyUI-ArchiGraph/Filename List πŸ¦β€πŸ”₯
ComfyUI Node

Filename List πŸ¦β€πŸ”₯

Generate your batch filenames before you've saved anything

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
Filename List πŸ¦β€πŸ”₯
    • filenames
    β—„num_files10β–Ί
    β—„filename_prefixAGβ–Ί
    β—„num_digit4β–Ί
    β—„num_start0β–Ί
    β—„optional_idx-1β–Ί

    Batching in ComfyUI usually hits the same wall: you render 10 images, and if your save node uses a fixed name, nine of them get overwritten. The classic fix is to include a batch index in the filename. This node is that fix, generalized - it generates the list of filenames before you have any output, so you can pair each batch item with its own name.

    How it works

    It's dead simple string math. Given a prefix, a digit count, a starting number, and a count, it produces zero-padded filenames like AG_0000.png, AG_0001.png, and so on:

    num_files = 10, prefix = "AG", num_digit = 4, num_start = 0
    β†’ ["AG_0000.png", "AG_0001.png", ..., "AG_0009.png"]
    

    The four required inputs map directly to that: num_files (how many), filename_prefix (default "AG"), num_digit (zero-padding width, default 4), num_start (where to start counting, default 0).

    Then there's optional_idx, the one that changes behavior. Leave it at -1 (default) and you get the full list. Set it to any other value and you get a single string for that one index - AG_0003.png - which is exactly what you want when you're inside an iteration loop (like the pack's Iterate Items) and each pass needs one specific filename.

    The output filenames is an * port, so it can carry either the list or the single string depending on how you used optional_idx.

    Where it fits

    The natural pairing is with the pack's iterate nodes: Iterate Items walks a list, Filename List (with optional_idx wired to the loop's index) hands each pass its own name, and a save-to-path node uses it. No more "how do I not overwrite batch outputs" - you generate the naming scheme up front.

    The traps

    • The extension is hardcoded to .png. There's no jpg/jpeg option. If you want PNG output this is perfect; if you're saving webp or jpg, this node's names won't match.
    • num_start can be non-zero - useful for resuming a run at index 20 without renumbering everything.
    • It's just string generation. Nothing gets written or read; the node has no idea whether a file exists. That's the point (it runs before saves), but don't expect it to check for collisions.

    Install

    ComfyUI Manager β†’ search ComfyUI-ArchiGraph, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/vincentfs/ComfyUI-ArchiGraph
    

    Restart and run the pack's install script once. This node is pure Python - no OpenCV involved.

    Verdict

    A tiny utility that only earns its keep inside a batch loop, but inside one it's the difference between "10 files, 9 overwritten" and "10 numbered files." Cheap, predictable, no surprises - the good kind of boring.

    CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ› οΈ Utils

    Inputs (5)

    NameTypeDefaultDescription
    num_filesINT10Number of filenames to generate.
    filename_prefixSTRINGAGPrefix for the filenames.
    num_digitINT4Number of digits in the filename.
    num_startINT0Starting number for the filename.
    optional_idxoptINT-1If specified (not -1), generate only the filename for this index.

    Outputs (1)

    NameTypeDescription
    filenames*β€”