Nodes/Nifty Nodes for ComfyUI/Batch Image Loader End
ComfyUI Node

Batch Image Loader End

Batch Image Loader End is where the loop actually lives — and where your files die

By Stibo·Created 7 months ago·Updated 7 days ago· 11
Batch Image Loader End
  • loop
  • values
  • count
  • filenames
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
  • value10
  • value11
  • value12
  • value13
  • value14
  • value15
  • value16
◄file_action▾►

The name makes it sound like a closing bracket. It isn't. Batch Image Loader End is the part of this loop that does the work: it applies your file action, applies your rename action, then starts the next iteration or finishes. If you only read one of the two articles about this pair, read this one - the loop's whole behavior lives here.

What it's for

Two jobs, on purpose:

  1. Bookkeeping between iterations. Every image that comes through gets optionally moved, renamed, or deleted. This is the "process 400 files overnight and have them sorted when you wake up" pattern - renders moved to done/, failures left in place by using none, source files deleted only after a save node has written the output.
  2. State plumbing. Its sixteen value slots carry values back to the matching slots on Start, so a counter, an accumulated filename list, or a running total can survive across iterations.

How it works

End is registered as an output node, which in ComfyUI means it's a terminus the executor runs back from. Each iteration, in order:

  1. It waits for any connected value slots to resolve - the source marks them lazy, and the author's tooltip says it plainly: the node waits for connected values before touching the input file. So a value that depends on the current image is safe to wire in.
  2. It applies file_action - none keeps the file, move moves it, delete removes it. Move takes a target_directory, relative to the loader's directory (default done) or absolute, created if missing, with subfolders preserved. Name collisions get a _1 suffix rather than an overwrite, so you won't silently lose a file to a naming clash.
  3. It applies rename_action in the file's new location - unless the file was deleted, in which case rename isn't offered.
  4. If there are files left, it clones the section of graph between the two nodes into the next iteration and hands it back to the executor. Otherwise it returns.

That last step is why the whole folder runs in one queue click, and why a big folder is a big graph: the body of your workflow gets duplicated per iteration, not looped in Python.

Inputs and outputs

  • loop - from Batch Image Loader Start. Not optional in any meaningful sense; the node does nothing without it.
  • file_action - none, move (+ target_directory), or delete.
  • rename_action - none; rename (filename prefix plus a five-digit counter, name_00001_.ext, extension kept); suffix (appends suffix before the extension); regex (regex_search / regex_replace, applied to the filename without extension, with \1 / \g<name> group references supported).

Outputs: count, the number of processed images; filenames, all processed names one per line, only populated after the last iteration; and value1…value16 holding each slot's value after the last iteration. Like Start, it's marked always-dirty by design.

Installing it

ComfyUI Manager → search Nifty Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Stibo/comfyui-nifty-nodes

Restart. The pack's declared dependencies (color-matcher, imageio-ffmpeg) come along with a Manager install and aren't needed here. This is a small, single-author pack with essentially no community write-ups, so the README and the source are the documentation - and the source is unusually readable for a loop node.

Two caveats straight from the README: it's tested with frontend 1.39, and untested with Nodes 2.0. Anything built on graph expansion is exactly what a frontend rewrite disturbs.

Where people get burned

  • delete is immediate and unconfirmed. There's no trash, no dry run. Do a first pass with none or move on a duplicate folder and inspect the result.
  • Renaming is not idempotent in the obvious way. Regex mode rewrites the stem each time it sees the file, and rename mode appends a counter - if both a move and a rename apply, read the tooltip order and test it on three files before trusting it on three hundred.
  • filenames looks empty mid-run. It's only available after the last iteration, so anything expecting the list during the loop (including values you feed back) is waiting on nothing.
  • Move targets resolve relative to the loader's directory, not the ComfyUI root. done inside a recursive run lands next to the images, not where you might expect from the Start node's absolute-path behavior.
  • Subfolder preservation cuts both ways. With recursive on, moving to done recreates the tree - great for keeping structure, surprising if you wanted everything in one flat folder.
Categorynifty/media

Inputs (3)

NameTypeDefaultDescription
loopNIFTY_BATCH_LOOP—
file_actionCOMBOApplied to the input file of the current iteration. Runs before the rename action.
valuesoptCOMFY_AUTOGROW_V3—

Outputs (18)

NameTypeDescription
countINTNumber of processed images.
filenamesSTRINGAll processed file names, one per line. Only available after the last iteration.
value1*Value of this slot after the last iteration.
value2*Value of this slot after the last iteration.
value3*Value of this slot after the last iteration.
value4*Value of this slot after the last iteration.
value5*Value of this slot after the last iteration.
value6*Value of this slot after the last iteration.
value7*Value of this slot after the last iteration.
value8*Value of this slot after the last iteration.
value9*Value of this slot after the last iteration.
value10*Value of this slot after the last iteration.
value11*Value of this slot after the last iteration.
value12*Value of this slot after the last iteration.
value13*Value of this slot after the last iteration.
value14*Value of this slot after the last iteration.
value15*Value of this slot after the last iteration.
value16*Value of this slot after the last iteration.