Nodes/Comfyui_TextBatch_aidec/Image Filename Processor
ComfyUI Node

Image Filename Processor

Pull the right filename out by index

By aidec·Created 2 years ago·Updated 9 months ago· 19
Image Filename Processor
    • filename
    • name_no_ext
    • extension
    • full_path
    • total_files
    • status
    filenames
    index0
    directory

    Small node, specific job, and it's the glue that makes aidec's batch img2img trick actually pay off. Load Images From Dir Batch hands you a big comma-joined string of all the filenames in a folder. Your queue node hands you an index - "I'm on image 7 right now." Image Filename Processor is what turns those two things into "…and image 7 is called portrait_042.png."

    Why do you care? Because that's how you make output images inherit the name of their source. In batch img2img you're feeding in a folder and generating a new version of each picture; without this, your results save as ComfyUI_00001 and you've lost track of what's what. Wire the filename through and every output keeps its original name, so the before-and-after pairs are obvious at a glance. For any batch you'll actually review afterward, that's the whole point.

    How it works

    You give it the full filenames string and an index; it splits the string, grabs the entry at that position, and breaks it into useful pieces - the full name, the name without extension, the extension on its own. Simple string surgery, but it closes the loop between "which image am I on" and "what should I call the result."

    The inputs that matter

    • filenames - the comma-joined string of names. Comes straight from Load Images From Dir Batch's filenames output (or full_paths if you want the whole path).
    • index - which one to pull. Feed this from your queue node's current_index so it tracks whatever image is being processed right now.
    • directory - the folder, used to build the full path output.

    Outputs: filename (the whole thing, e.g. portrait_042.png), name_no_ext (portrait_042 - usually what you want for a Save Image prefix), extension, full_path, total_files, and status. Route name_no_ext into your Save Image node's filename and you're done.

    The canonical wiring, straight from the author: Load Images From Dir Batch filenames → this node's filenames, and Image Queue Processor current_index → this node's index. That combination is the pack's headline batch-img2img pattern.

    Installing it

    cd ComfyUI/custom_nodes && git clone https://github.com/aidec/Comfyui_TextBatch_aidec, then restart ComfyUI (or ComfyUI Manager → Install via Git URL). No models, no heavy dependencies. It's under the TextBatch category.

    Where people get burned

    • Index off by one, or off the end. The index has to come from the same queue that's driving the images, or the name won't match the picture. If they drift apart you'll save results under the wrong source name - worse than no name at all, because it looks correct. Keep both fed from one queue node.
    • Wrong string in. filenames expects the comma-joined format this pack produces. Hand it some other node's output shape and the split won't line up.
    • full_paths vs filenames. If you feed it full paths but only wanted the bare name, use the name_no_ext output rather than trying to reformat downstream - it already strips the folder and extension for you.

    It does one thing, but it's the one thing that makes named batch outputs work. Keep it in the batch-img2img toolkit.

    CategoryTextBatch

    Inputs (3)

    NameTypeDefaultDescription
    filenamesSTRING
    indexINT0
    directorySTRING

    Outputs (6)

    NameTypeDescription
    filenameSTRING
    name_no_extSTRING
    extensionSTRING
    full_pathSTRING
    total_filesINT
    statusSTRING