Nodes/MTB Nodes/Batch From Folder (mtb)
ComfyUI Node Runs on cloud

Batch From Folder (mtb)

Load a batch of images from a folder in ComfyUI

By melMass·Created 3 years ago·Updated about a month ago· 721
Batch From Folder (mtb)
  • passthrough_image
  • images
enabletrue
folder_path
modelatest
count10
filter*

When you want to run a whole folder of images through a workflow - batch upscale, batch caption, batch style transfer - you need a loader that grabs many files at once instead of one. Batch From Folder (mtb) does that, and it adds the two things that make it actually pleasant: sorting and filtering.

Point it at a directory, tell it how many images and in what order, and it hands back an image batch. The order options are the useful part. "Latest" grabs the most recently modified files, which is perfect for picking up whatever another process just wrote - say you're pulling the freshest renders out of an output folder. "Oldest" walks from the start. "Random" gives you a sampler for quick tests without hand-picking. Combine that with a filename filter and you can point it at a messy folder and still get exactly the subset you meant.

It's in the batch corner of MTB Nodes (comfy_mtb) by melMass, alongside the pack's other batch-manipulation helpers.

How it works

It lists the files in folder_path, applies your glob filter to keep only the ones you want, sorts them by the mode you picked, takes the first count of them, loads each into a tensor, and stacks them into one image batch. It's ordinary filesystem + PIL work - no model, no network.

The inputs and outputs that matter

  • folder_path - the directory to read. An absolute path is safest; the folder has to be reachable by the machine running ComfyUI, not your laptop if that's a different box.
  • mode (latest / oldest / random, default latest) - the selection order. latest is the one you'll use most: it's how you pick up "whatever just landed here."
  • count (default 10) - how many images to pull. It caps how big the batch gets.
  • filter (default *) - a glob pattern. *.png for PNGs only, render_* for a prefix, * for everything. This is what saves you when the folder has junk in it.
  • enable (default on) - a simple on/off. Turn it off to skip the load without deleting the node.
  • passthrough_image (optional) - an image you can route through when you'd rather bypass the folder load, handy for toggling between "folder mode" and "single image" in one graph.

Output is images (IMAGE) - a batch you feed into whatever you're running per-frame.

How to install it

ComfyUI Manager: search MTB Nodes, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/melMass/comfy_mtb

then restart. No models or heavy deps for this one - it's filesystem plumbing.

Common issues & troubleshooting

Mismatched sizes error out downstream. A batch is a single tensor, so every image in it has to share the same dimensions. If your folder mixes resolutions, the stack will complain - resize to a common size first, or filter down to images that already match.

It loaded nothing / the wrong files. Check the filter. A pattern like *.jpg silently skips your .pngs. Set it to * to confirm the folder path itself is right, then tighten the filter.

"Latest" isn't grabbing what I expected. latest sorts by file modification time, not by name or by the number in the filename. If your files were copied or touched out of order, the mod-times won't match your intuition. Use oldest or rename if you need strict name order.

Path not found on a remote/headless setup. The path is resolved on the server running ComfyUI. A folder that exists on your desktop doesn't exist inside a container or on a remote GPU box unless it's mounted there.

Categorymtb/batch

Inputs (6)

NameTypeDefaultDescription
enableBOOLEANtrueEnable or disable the node. If disabled, returns passthrough_image or an empty tensor.
folder_pathSTRINGPath to the folder containing images. Relative paths are resolved to the ComfyUI output directory.
modeCOMBOlatestHow to select images: latest, oldest, or random.
countINT101–1000Number of images to load from the folder.
filterSTRING*Glob filter for image filenames (e.g. *.png).
passthrough_imageoptIMAGEIf provided and node is disabled, this image is passed through instead of returning an empty tensor.

Outputs (1)

NameTypeDescription
imagesIMAGE