Save Image with Exact Filename
Want a filename you actually chose? This Save node stops guessing
- image
Stock ComfyUI's Save Image node is built for one job and it does it well: save the image, show a preview, append a random four-digit suffix so nothing collides. That's great when a human is browsing outputs. It's useless when your pipeline needs to write frame_0042.png and mean it. This node - "Save Image with Exact Filename" from the ComfyForEach pack - writes exactly the filename you hand it, into a directory it builds from your task id. No counter, no random digits, no debate.
You reach for it in a batch loop. The pack's whole design is: load a folder of PNGs, pick them one at a time by index, process each, and save each under a name that still tells you which source image it came from. That last step is what this node exists for, and it's the natural partner to the pack's FolderImageLoaderNode and IndexedNameSelectorNode - load the names, index them in lockstep with the images, feed the string straight into this node's filename input.
How it works
The mechanism is plain Python, which is refreshing after some of the plumbing-heavy Save nodes out there. It joins your path as root_path/task_id/suffix_path, creates the directory tree if it doesn't exist (os.makedirs(..., exist_ok=True)), takes the first frame of the incoming image batch, converts the tensor back to bytes, and writes the file.
Two details in there are worth knowing before they bite you. First, it only saves image[0] - the first frame of a batch. Feed it a 4-image batch and you get one file, not four. Second, it converts everything to RGBA and never converts back. That has a side effect we'll get to.
Inputs that matter
Only five, and a beginner sets three of them:
filename- the exact file name. Defaultoutput.png. This is the whole point; feed it from a string node or a name selector.root_path- base directory, default./output.task_id- one level of the folder structure (see below), defaultabc123.suffix_path- optional extra subdirectory; leave empty and nothing breaks.image- the IMAGE tensor to save.
It's a terminal node: no outputs, and ComfyUI treats it as one of your output nodes.
Install
ComfyUI Manager, search for ComfyForEach, or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/pupba/Comfy_ForEach
cd Comfy_ForEach
pip install -r requirements.txt
Then restart ComfyUI. The dependencies are pillow, boto3, opencv-python-headless, numpy, and torch (which you already have - ComfyUI ships it). No model downloads. The author's README also shows patches to ComfyUI's execution.py, main.py, and logger - those are only for the pack's AWS error-reporting story. Ignore them for local saving.
Where people get burned
The RGBA thing is the big one. Because it always converts to RGBA, a filename like out.jpg will throw cannot write mode RGBA as JPEG from PIL. This node is effectively PNG-only. Want JPGs? Save PNG here and convert downstream. Also remember ./output is relative to wherever you launched ComfyUI, not to the pack folder - a "file saved where?" panic is a launch-directory problem more often than a node problem.
One more honest note: this pack has essentially no community footprint - there are no threads to point you at, which means when it breaks, it's on you to read the error. The good news is the errors are readable and the source is short. This is a small, sharp tool from the same author who built the Rabbit-Hole pipeline project, and it's fine to use it that way: for what it does, it does exactly what it says.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| filename | STRING | output.png | — |
| root_path | STRING | ./output | — |
| task_id | STRING | abc123 | — |
| suffix_path | STRING | — |
Outputs (0)
No outputs