XB-BOX - Batch Folder Loader
Load one image at a time from a folder, stepper built in
- IMAGE
- MASK
- FILE_NAME
- TOTAL_COUNT
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:
- Lists every image (
png,jpg,jpeg,webp,bmp,jfif) in thedirectoryyou give it. - Sorts them naturally -
img2.pngbeforeimg10.png, the way a human expects, not the string-sort ComfyUI often gives you. - Picks the current file as
seed % total_count, soseed = 0is the first image,seed = 1the 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 theincrementcontrol_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/panel1or/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.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| seed | INT | 00–9999999 | Built-in auto-stepper using the seed mechanism |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| FILE_NAME | STRING | — |
| TOTAL_COUNT | STRING | — |