Get Counter In Output Folder
The output folder counter
- File Counter
This node is one input, one output, and one job: tell you what the next number should be. "Get Counter In Output Folder" (that's its on-screen name, even though the class is GetFileCountInOutputFolder) looks at the folder where ComfyUI saves images, counts what's already there, and hands you an integer you can use to make sure your next batch never clobbers the last one.
If you've done any real ComfyUI work you've hit the default filename situation: ComfyUI_00001_-style names that are fine until you batch 50 images and can't tell which is which, or you set a fixed Save Image filename and quietly overwrite yesterday's good run. The fix people reach for is numbered filenames, and this node exists to supply the number.
How it works
Give it a path - a directory name, or a path relative to ComfyUI's configured output folder. So "faces" checks ComfyUI/output/faces/. It counts every .png in there and returns the count. If the directory doesn't exist, it returns 0 rather than erroring, which is handy for a first run.
Where it gets clever is filename prefixes. The author's preferred save format is 00000 - prompt.png, and the node parses those leading numbers: it scans the files, finds the highest numeric prefix, and returns that plus one. So eight files in the folder with the highest prefix at 00010 gives you 11 - the next free slot - not 8. If nothing has a numeric prefix it just returns the plain file count. It only cares about .png, so an extra 00011.jpg in the same folder won't throw it off.
Because it sets IS_CHANGED to always-fire, the node re-evaluates on every queue run rather than caching - which is exactly what you want from a counter, even if ComfyUI purists grumble about nodes that never go green.
Wiring it up
The single output, File Counter (INT), wants to become a filename. The natural combo is the same pack's Format Int To String: pipe this counter in, pad it to four or five digits, then concatenate that string with your prompt text into a Save Image filename. You get 00011 - my prompt.png with zero manual number-keeping.
Get Counter In Output Folder (path: "batch1")
→ Format Int To String (number_digits: 5)
→ [string concat] " - " + prompt
→ Save Image (filename)
Installing it
ComfyUI Manager → search "KaleidiaNodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Kaleidia/KaleidiaNodes
# restart ComfyUI
No dependencies beyond what ComfyUI already ships, no models.
Where people get burned
The path is relative to your output directory - throw a full absolute path at it and it will likely just return 0. And the prefix logic is best-effort: it reads whatever digits a filename starts with, so a file named 10 best prompts.png would count as prefix 10 and push your next number to 11 even though it's not part of your sequence. Keep your output folders tidy with just your numbered saves and it behaves. It's a small, specific tool - but for anyone doing repeated numbered batches, it quietly removes a real annoyance.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| File Counter | INT | — |