Nodes/ComfyUI-CustomNodePacks/Folder Version Variant (per output)
ComfyUI Node

Folder Version Variant (per output)

Tagging each output of a single render

By Code2Collapse·Created 7 months ago·Updated 2 days ago· 56
Folder Version Variant (per output)
    • filename_prefix
    • subfolder_path
    • output_filename
    • report
    filename_prefix
    suffix
    modesubfolder
    prefix
    version_string
    extension

    The problem

    One render session produces several files: the mp4, a PNG sequence, an EXR sequence, a matted version of the mp4, maybe a plate. You want all of them filed under the same version - shot_a/v004/… - because they came out of the same run, but you want different names so you can tell them apart and so both sequence formats don't end up sharing a directory with thousands of files each.

    Without something like this you get one of two bad outcomes: every output lands under its own version number (so "v004" means four different things), or you start bolting Concatenate nodes onto your filename prefixes to fake the tags, which is how you end up with a _masked that sorts in the wrong place.

    Folder Version Variant sits between the incrementer and each save node. It re-tags the path without touching the version. Every variant fed from the same incrementer's filename_prefix lands on the same vNNN.

    Inputs

    • filename_prefix - connect the Folder Version Incrementer's filename_prefix output. This is a forced input, so there's no ambiguity about where it comes from.
    • suffix - the tag for this output, e.g. _masked, _exr, _png. Leave it empty for the one output that doesn't need a tag.
    • mode - where the tag goes, and this is the interesting choice:
      • filenameshot_a/v004/shot_a_masked.mov. Everything in one folder, told apart by name.
      • subfolder (default) → shot_a/v004/masked/shot_a.mov. One folder per output inside the version. The tooltip's own reasoning is the right one: use this for EXR sequences, because thousands of files shouldn't share a directory with anything else.
      • foldershot_a_masked/v004/shot_a.mov. A separate top-level tree, still on the same version.
    • prefix (optional) - a tag placed before the name instead of after. It exists because faking a prefix with a suffix sorts in the wrong order - shot_prev_masked sorts under p, not under shot - which is the entire reason to have a prefix at all.
    • version_string (optional) - connect the incrementer's version_string and a subfolder tag gets inserted immediately after the version directory (v004/masked/…) rather than being appended wherever the path already ended.
    • extension (optional) - e.g. .mov, used only to build the output_filename output. Most save nodes take filename_prefix and add their own extension, so leave this empty unless you're feeding something that wants a full name.

    Outputs: filename_prefix (the re-tagged one - wire this to the save node), subfolder_path (directory part only), output_filename (full name including the extension, when one was given), and report, which states what was tagged, where, and what stayed shared. The report is the output you read when two outputs have ended up in unexpected places.

    Things it will tell you off for

    The node raises a clear error rather than silently doing something odd, in three cases worth knowing:

    • A tag made only of separator characters (_, -, ., spaces) in subfolder mode would create a folder with no name. It refuses, with the suggestion to use masked or _masked.
    • folder mode with a prefix that has no directory part - there's no top folder to tag. Use filename mode for a bare name.
    • An unknown mode (only relevant if something is passing values in programmatically).

    And if both tags are empty, it returns the path unchanged. That's a no-op, not a bug - an untagged output in the middle of a set is a legitimate case.

    A worked layout

    [Folder Version Incrementer]  →  version_string, filename_prefix
            ├── [Variant] suffix "_masked", mode subfolder, version_string ─→ mask save
            ├── [Variant] suffix "_exr",    mode subfolder, version_string ─→ EXR sequence
            └── [Variant] suffix "",        mode subfolder, version_string ─→ main mp4
    

    Everything lands under shot_a/v004/, with the EXR sequence in its own subdirectory and the untagged output at the top. If you'd rather read the tree by filename, switch all three to filename mode and you get one flat folder.

    Install

    ComfyUI Manager → search "CustomNodePacks", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks
    

    Restart ComfyUI. String manipulation only - no models, no VRAM, no file I/O. Unlike the incrementer, this node has no side effect, so ordinary result caching is correct for it: same inputs, same path, and it deliberately doesn't expose a trigger input. The usual pack caveat stands - check pip list before installing requirements.txt, since the list includes packages ComfyUI already provides.

    Common issues

    • A variant ended up on a different version. It's fed from a different incrementer, or from the save node's own prefix instead of the incrementer's filename_prefix. One incrementer per set.
    • Tags landed in a strange place in the path. Wire version_string as well. Without it, a subfolder tag just gets appended to the end of whatever the incrementer already produced.
    • The EXR sequence is choking the folder listing. That's what subfolder mode is for.
    Categoryutils

    Inputs (6)

    NameTypeDefaultDescription
    filename_prefixSTRINGConnect the Folder Version Incrementer's `filename_prefix` output. Every variant fed from the same incrementer lands under the same version.
    suffixSTRINGTag for THIS output, e.g. '_masked', '_exr', '_png'. Leave empty for the one output that needs no tag.
    modeCOMBOsubfolderWhere the tag goes. filename -> shot_a/v004/shot_a_masked.mov everything in one folder, told apart by name subfolder -> shot_a/v004/masked/shot_a.mov one folder per output INSIDE the version. Use this for exr sequences - thousands of files should not share a directory with anything else. folder -> shot_a_masked/v004/shot_a.mov a separate top-level tree, still on the same version.
    prefixoptSTRINGTag placed BEFORE the name instead of after. Offered because a prefix faked with a suffix sorts in the wrong order, which is the whole reason to use one.
    version_stringoptSTRINGOptional. Connect the incrementer's `version_string` so a subfolder tag is placed immediately after the version directory rather than at the end of the path.
    extensionoptSTRINGOptional extension for the `output_filename` output, e.g. '.mov'. Most save nodes take `filename_prefix` and add their own.

    Outputs (4)

    NameTypeDescription
    filename_prefixSTRINGRe-tagged prefix. Wire to the save node's filename_prefix.
    subfolder_pathSTRINGDirectory part only.
    output_filenameSTRINGFull name including the extension, when one was given.
    reportSTRINGWhat was tagged and where, and what stayed shared.