Nougan Load Image Batch From Folder π
Point it at a directory and press Run once
- image
- mask
- filename
- path
- index
- total
ComfyUI has no node that says "load every image in this directory, one at a time, in order." Core Load Image gives you a dropdown of files you already uploaded and no path out the other side. That's fine until you're captioning a LoRA dataset, where the job is 400 images and each one needs to go through the same graph and land in a .txt file next to itself. This node is the missing half.
FolderImageBatchLoader is one of two nodes in Nougan Nodes' dataset-captioning family, documented in docs/dataset-captioning.md. Its job is narrow: read a folder, sort the files, load one of them, and hand you enough information - including the real path - to do something with that image and then move on. Pair it with SaveCaptionMatchImage and you have a folder captioner; pair it with an upscaler and you have batch upscaling.
How the whole-folder run works (this is the part worth understanding)
There is no Python loop. The node loads exactly one image per execution; the looping is done by the frontend extension in web/nougan_folder_batch.js.
The mechanism: after the node runs it returns batch_info: [index, total] as UI data. The JS listens for that, and when the graph finishes successfully, if auto_run_folder is on, it bumps the index widget and calls queuePrompt(0, 1) - one more prompt, one more image. Repeat until the last file, at which point index rewinds to 0 so your next Run starts from the top. An error or an Interrupt clears the pending state, so the chain stops instead of grinding on through a broken run.
Two consequences fall straight out of that design. Leave the queue's batch count at 1 - the node does its own looping, and a batch count of 2 will interleave two folders' worth of runs. And the JS file is load-bearing: without it the node captions exactly one image and stops, looking for all the world like it worked. That's the number one thing people hit.
The rest is predictable. The extension set is png, jpg, jpeg, jfif, webp, bmp, tif, tiff, gif (first frame only). numeric sorting is a natural sort, so img2 comes before img10; alphabetical is plain case-insensitive AβZ. Images get EXIF rotation applied, and the node stashes a downscaled preview (max 1024px) in ComfyUI's temp directory - your originals are never touched. A π Refresh folder button counts the folder and shows the first and last filename before you commit to a long run.
The inputs that matter
Only four, and you'll touch two of them.
folder_path- the directory. Windows "Copy as path" with the quotes is fine, it strips them, and~and environment variables get expanded. Subfolders are not scanned; that's a hard rule, not a setting.sort_mode-numeric (001, 002, 10...)oralphabetical. Use numeric if your files are numbered, unless you enjoyimg10landing betweenimg1andimg2.index- which image to start on. Out-of-range wraps around instead of erroring.auto_run_folder- the toggle, labelled run whole folder / single image. Use single image while you're still tuning the prompt, because nobody wants to discover the wrong trigger word 400 captions in.
What comes out
image and mask (inverted alpha, same convention as core Load Image; zeros if there's no alpha) go downstream to whatever you're doing. Then the two that matter for a dataset: filename is the stem - 044, not 044.jpeg, which is exactly what a caption file has to be named after - and path is the full path. index and total are there if you want to log progress. Wire path, not filename: path carries the folder, and the folder is how the caption knows where to land.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/Winnougan/Nougan_Nodes
# restart ComfyUI
Or search Nougan in ComfyUI Manager. Node IDs here are deliberately unprefixed (FolderImageBatchLoader) so workflows built with the earlier standalone version of this loader still open - which is also why a leftover standalone copy causes trouble. Both nodes live in one file with no dependencies of their own; the pack's pyproject.toml declares an empty dependency list, and these two need only torch, numpy and PIL, which ComfyUI ships. Boot should print [Nougan] β
Folder Batch Loader + Save Caption loaded (2 nodes).
When it stops cooperating
It captions one image and quits. The frontend extension didn't load. Hard refresh (Ctrl+F5) and check that nougan_folder_batch.js sits at the top level of the pack's web/ folder, not in a subdirectory.
Every image gets queued twice. You still have an old standalone copy of this loader in custom_nodes. Delete it, restart, and hard refresh - the stale JS may be cached in the browser too.
Folder not found or No images found. Either the path is wrong or the images are in subfolders, which aren't scanned. Hit Refresh; it tells you what the node can actually see.
Blank preview before the first run. Normal. The preview appears after the node has executed once.
Resuming mid-folder. Set index where you want to pick up. Combined with skip if exists on the saver, that's how you finish a half-captioned dataset without redoing work you've already paid for.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | β | |
| sort_mode | COMBO | 2 options: numeric (001, 002, 10...), alphabetical | |
| index | INT | 00β16777215 | β |
| auto_run_folder | BOOLEAN | true | β |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| mask | MASK | β |
| filename | STRING | β |
| path | STRING | β |
| index | INT | β |
| total | INT | β |