Nodes/Image Processing Suite for ComfyUI/Folder Metadata by Node Name
ComfyUI Node

Folder Metadata by Node Name

Pull one specific node's text out of every image in a folder

By marcoc2·Created 2 years ago·Updated 5 months ago· 1
Folder Metadata by Node Name
    • images
    • extracted_texts
    directory
    node_nameCLIPTextEncode

    Folder Metadata by Node Name is the dataset-prep node that pulls out one specific prompt instead of the whole bundle. The general prompt-extraction approach grabs "the main positive" by guessing. This one is surgically precise: you give it a folder and a node name, and for every image it extracts the text that was entered into that exact node in the workflow that generated the image. Negative prompts, a specific caption field, whatever you labeled a node - you can reach in and take just that.

    Why this matters: if you've built a dataset by generating images with a workflow that stores distinct info in different nodes - say a caption in a CLIPTextEncode and a style tag in a Show Text node - the embedded PNG metadata (ComfyUI writes both the execution graph and the UI workflow into the file by default) holds all of it, but the boring generic extractor can only hand you one blob. This node lets you split that blob by node, which is the difference between a dataset you can train on and a pile of images with unlabeled metadata.

    The matching logic is worth understanding because it determines what to type in node_name (default CLIPTextEncode). It checks, in order: a custom another_tag metadata key the pack's own save node writes (best for batch labeling), then the embedded execution graph where it matches against each node's _meta.title or class_type, then the UI workflow JSON (which is how it reaches text in Display Any / Show Text style nodes), and finally falls back to A1111's parameters block. Matching is case-insensitive and matches either a node's title or its class type. So if your CLIPTextEncode is titled "My Prompt," both "CLIPTextEncode" and "my prompt" work.

    Outputs are two lists that line up by index: images (all the image tensors, one per file) and extracted_texts (the matching string for each). That parallel-list design is the whole point - you can zip them into a training captions file.

    The gotchas are honest ones. The directory is a plain path string (use absolute paths; no file-picker here), scanning is top-level only, and the text extraction only works if the PNG actually carries ComfyUI metadata - images saved with Save Image default do; images that had metadata stripped return "Prompt not found." And it's heuristic under the hood: for a node with multiple string inputs it takes the first non-empty one it finds, so it's great for single-text nodes and slightly guessy for complex ones.

    Install: ComfyUI Manager → search "AnotherUtils", or clone https://github.com/marcoc2/ComfyUI-AnotherUtils into custom_nodes, restart. No dependencies beyond PIL and the standard library.

    CategoryAnotherUtils/loaders

    Inputs (2)

    NameTypeDefaultDescription
    directorySTRING
    node_nameSTRINGCLIPTextEncode

    Outputs (2)

    NameTypeDescription
    imagesIMAGE
    extracted_textsSTRING