Nodes/ComfyUI_PromptExtractor_nodes/DJZ Prompt Extractor V2 (Batch)
ComfyUI Node

DJZ Prompt Extractor V2 (Batch)

Batch prompt mining, the V2 way — offsets and system-prompt filtering built in

By MushroomFleet·Created 7 months ago·Updated 5 months ago· 2
DJZ Prompt Extractor V2 (Batch)
    • prompts_list
    • filenames_list
    • processed_count
    directory_path
    offset1
    max_images10
    ignore_system_prompttrue

    The single-image V2 node (DJZ Prompt Extractor V2) fixed the pack's biggest weakness: instead of trusting a classifier to tell positive from negative, it ranks every string in the metadata by length and lets you pick by position. DJZ Prompt Extractor V2 (Batch) takes that same approach and runs it across a whole directory. Point it at your output folder, and it extracts the Nth-longest string from every PNG in one go - no dragging a hundred images onto the canvas.

    How it works

    For each PNG in the directory, it reads the embedded workflow/prompt JSON from the file's tEXt/iTXt chunks, recursively collects every string, sorts them longest-first, and returns the one at your offset. The clever bit is that the ignore_system_prompt filter from V2 is here too: modern Wan / LLM-encoder workflows stuff giant system prompts into the metadata, and those would otherwise win "longest string" every single time. With the filter on (the default), they're removed before ranking, so offset 1 actually gives you the generation prompt.

    Inputs that matter

    • directory_path - the folder to scan. The one you set every time; absolute paths are safest.
    • offset - which string to pull from each image, 1–100, default 1. Bump it to 2 or 3 when offset 1 keeps returning the wrong thing across the batch.
    • max_images - 1–100, default 10. The cap on files processed.
    • ignore_system_prompt - true by default; leave it unless you want the system prompt.

    Outputs

    • prompts_list - the selected string from each file, joined with ---.
    • filenames_list - matching filenames, one per line, in the same order.
    • processed_count - how many files actually yielded a prompt, a nice sanity check the V1 batch node doesn't give you. If it's lower than you expected, some files had no readable metadata - usually because they were re-saved or uploaded.

    Wire the first two into a Show Text node to read the haul. They're plain STRING outputs despite the list-ish names - one big block each, not actual ComfyUI list types.

    Install and gotchas

    Standard for this pack: ComfyUI Manager, search "DJZ Prompt Extractor", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MushroomFleet/ComfyUI_PromptExtractor_nodes
    

    Restart after. No extra dependencies, no model downloads.

    The gotchas are the family ones. Metadata only survives in original ComfyUI PNGs - anything through social media or an editor is a write-off. And the batch slices the file list by max_images in directory order without sorting, so the first N files may not be the N you wanted; check filenames_list before trusting the pairing. One more V2-specific trap: if your workflow's longest string isn't a prompt (some models embed model names, seed strings, or other metadata that outranks your prompt), offset 1 won't be right and you'll need to experiment with the offset - which is exactly what this node's design is for.

    CategoryDJZ-Nodes

    Inputs (4)

    NameTypeDefaultDescription
    directory_pathSTRING
    offsetoptINT11–100Which string to extract from each image: 1=longest, 2=second longest, etc.
    max_imagesoptINT101–100
    ignore_system_promptoptBOOLEANtrue

    Outputs (3)

    NameTypeDescription
    prompts_listSTRING
    filenames_listSTRING
    processed_countINT