Nodes/ArtyClaw Comfy Nodes/Load Sidecar Prompt (.txt) – List
ComfyUI Node

Load Sidecar Prompt (.txt) – List

Reuse the Original Prompt Hiding Beside Every Image

By artyclaw·Created 5 months ago·Updated 5 months ago· 0
Load Sidecar Prompt (.txt) – List
    • prompt_texts
    filenames

    The "sidecar" pattern is one of those things ComfyUI users keep re-inventing: an image named img001.png sits next to a text file named img001.txt that holds the prompt that made it. Load Sidecar Prompt (.txt) is the node that reads those files in bulk. Feed it a list of image filenames, and it returns the corresponding .txt contents as a list - perfect for re-running an old generation with tweaks, building a dataset of prompt/image pairs, or just recovering what you did last week.

    It's from artyclaw/artyclaw-comfy, and it solves a problem that appears the moment you start organizing generations into folders with sidecar prompts. The display name's "â€" is just a mojibake dash from the pack's UTF-8 handling - ignore it; the node is fine.

    How it works

    For every filename in the input list, it:

    1. Strips the extension (img001.pngimg001).
    2. Appends .txt (img001.txt).
    3. If that file exists, reads it and returns the full contents; if not, returns an empty string.

    The output is a list that lines up one-to-one with the input filenames, so an image list and its prompt list stay index-aligned - which is exactly what you need when a batch node is iterating both. Missing sidecars don't error; they just produce empty strings, keeping the pipeline alive.

    Inputs and output

    One input, filenames - a multiline STRING marked forceInput, which means it's meant to be wired from a node that emits a list of filenames (like SimpleDirLoader's path_list or SimpleFolderParser's lists). One output, prompt_texts, typed STRING and flagged as a list (is_list: true), so ComfyUI knows downstream nodes will iterate it.

    Install

    ComfyUI Manager → search ArtyClaw Comfy Nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/artyclaw/artyclaw-comfy
    

    Restart. Pure Python stdlib (os).

    Where people get burned

    The big one is path resolution. The node looks for the .txt next to whatever path you hand it - if your filenames are bare names (img001.png) but the images live in a subfolder, it looks for img001.txt in the current working directory, not next to the images. Wire it from a node that outputs full paths and this disappears. Second, a filename with no extension still gets .txt appended to the whole string, so img001img001.txt (works) but img001.finalimg001.final.txt (surprise). And sidecar files created by A1111-style tools sometimes have a trailing newline; the node doesn't strip it, so you may want a trim node downstream before the text hits an encoder. Small caveats, but they're the difference between "works" and "works on the first try."

    Categorytext/utils

    Inputs (1)

    NameTypeDefaultDescription
    filenamesSTRING

    Outputs (1)

    NameTypeDescription
    prompt_textsSTRING