Nodes/ComfyUI-FilePathsFromFolder/File Paths For Loop End
ComfyUI Node

File Paths For Loop End

The loop terminator that's actually an output node

By RockyHong·Created 7 months ago·Updated 7 months ago· 1
File Paths For Loop End
  • passthrough
  • processed_count
current_index0

Every good loop needs a closing bracket, and "File Paths For Loop End" is the closing bracket for the ComfyUI-FilePathsFromFolder pack's built-in loop. You start with File Paths For Loop Start, you run your graph, and you land here. If the Start node is the for keyword, this is the } - the thing that says "the loop is over, count what we did."

It looks deceptively small - one required input, one optional input, one integer output - but the important part is invisible on the canvas. The class sets OUTPUT_NODE = True, which in ComfyUI's execution model means this node always runs, and the engine works its cache backward from output nodes (see the node-plumbing knowledge base for the full mechanism). That single flag is why closing the loop through this node actually forces the loop's contents to execute instead of getting pruned as "not needed for the final image." It's not a magic iterator; it's an anchor that guarantees the loop body runs.

The inputs

  • current_index - wire this from File Paths For Loop Start.current_index. It's an INT with forceInput, meaning it's a socket, not a widget. Because the Start node outputs a list, this node reads the whole list at once (it declares INPUT_IS_LIST = True).
  • passthrough - optional, any type. This is the "anchor" input the README tells you to wire from FilePathsEnsureExecution.passthrough. Doing so drags your save/write/export route into the loop's guaranteed-execution path, which is exactly how you make sure your outputs actually get written instead of skipped. You can also leave it unwired and the loop still works; the only thing you lose is the anchoring.

The output

  • processed_count - an INT telling you how many iterations happened. The code computes it as len(current_index) - the number of items in the incoming index list - or 1 if it somehow isn't a list. Handy for logging, for a "done" signal, or just for the quiet satisfaction of seeing 400 come back after a 400-file run.

How to wire the whole thing

File Paths For Loop Start.current_indexFile Paths For Loop End.current_index. Optionally: your processing chain → FilePathsEnsureExecution inputs → .passthrough → this node's passthrough. The README's example does exactly that, and it's the difference between "the images appeared in my output folder" and "why did nothing get saved."

Common confusion

People sometimes expect the End node to do something to the files - pick the next one, apply a transform, whatever. It doesn't. It's a terminator and a counter; all the per-file work happens between Start and End, in your own graph. The other classic confusion is skipping it entirely because the loop "seems to work" in preview. Preview will happily show you batched outputs without the End node, and then your Save Image nodes may or may not fire reliably. Use the End node. It's two wires and it makes the loop's execution contract explicit.

Part of the same dependency-free pack, so install is just the one clone (git clone https://github.com/RockyHong/ComfyUI-FilePathsFromFolder.git into custom_nodes) and a restart - find it in the menu as "File Paths For Loop End."

CategoryFilePathsFromFolder/Loop

Inputs (2)

NameTypeDefaultDescription
current_indexINT0
passthroughopt*

Outputs (1)

NameTypeDescription
processed_countINT