Nodes/XB_ToolBox/XB-BOX - Batch Folder Loader
ComfyUI Node

XB-BOX - Batch Folder Loader

Load one image at a time from a folder, stepper built in

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB-BOX - Batch Folder Loader
    • IMAGE
    • MASK
    • FILE_NAME
    • TOTAL_COUNT
    directory
    seed0

    ComfyUI's stock image loaders want you to pick one file from a dropdown. XB_BatchFolderLoader does something different: you point it at a folder on disk and it serves you the images from it one at a time, advancing through them with its seed field. Same workflow, re-run it, get the next image. If you've ever built a batch pipeline by dragging the same Load Image node fifty times, this is the version that doesn't make you.

    It's categorized under XB_ToolBox/Batch_Process, and it's aimed at the "run this whole workflow over a directory of inputs" job - img2img a folder, upscale a folder, caption a folder. The node doesn't loop itself (it's one image per run), but a seed stepper plus "queue" makes it a one-button assembly line.

    How it works

    At load time the node:

    1. Lists every image (png, jpg, jpeg, webp, bmp, jfif) in the directory you give it.
    2. Sorts them naturally - img2.png before img10.png, the way a human expects, not the string-sort ComfyUI often gives you.
    3. Picks the current file as seed % total_count, so seed = 0 is the first image, seed = 1 the second, and so on. The seed field's own tooltip calls it a "built-in auto-stepper" - bump it by one per run, or use the increment control_after_generate setting to do it automatically.

    One important quirk: directory is an absolute OS path, not a ComfyUI-folder path. The node raises FileNotFoundError if you hand it a relative path or a non-existent directory - this is the opposite of the usual "put it in input/" workflow, and it's the first thing that trips people up.

    The outputs are the interesting part:

    • IMAGE - the current image as a tensor.
    • MASK - its alpha channel if present (inverted to the ComfyUI mask convention), or a zero mask if not.
    • FILE_NAME - a formatted string Images/Batch/YYYY-MM-DD/<name>, built for feeding a save node that writes into a dated batch folder.
    • TOTAL_COUNT - a STRING like Total images detected: 42, which is the node's own progress indicator.

    The inputs that matter

    • directory - absolute path to your folder.
    • seed - the stepper. 0 = first file (natural-sorted), 1 = second, etc.

    Installing

    Part of XB_ToolBox - ComfyUI Manager → XB_ToolBox, or

    cd ComfyUI/custom_nodes
    git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
    

    restart, no extra dependencies.

    Common issues

    • "Directory not found" - you gave a relative path. Use the full path, e.g. D:/comics/panel1 or /home/user/pics.
    • Same image every time - seed isn't stepping. Set the seed's control_after_generate to increment.
    • Wrong order - it natural-sorts, so a2 < a10. If your filenames aren't zero-padded, accept the order or rename.
    • MASK is all black - that's the "no alpha channel" case, correctly reported as an empty mask. Not a bug.

    The catch: because it loads one file per run, it's not a true "process everything" node - you drive it with the seed stepper rather than a batch size. That's a feature for some workflows (watch each result before advancing) and a mild annoyance for others, where a bulk loader would be nicer.

    CategoryXB_ToolBox/Batch_Process

    Inputs (2)

    NameTypeDefaultDescription
    directorySTRING
    seedINT00–9999999Built-in auto-stepper using the seed mechanism

    Outputs (4)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK
    FILE_NAMESTRING
    TOTAL_COUNTSTRING