Batch Image Saver
Keep your filenames through a batch, mostly
- images
- saved_paths
Here's the thing that sends people to this node: ComfyUI's built-in Save Image renames everything to anonymous ComfyUI_00001_.png - sequential, nameless, and useless when you're batch-processing a folder of files you actually care about. Batch Image Saver is the "save the whole batch at once and keep the names" node from the cedarconnor/comfyui-BatchNameLoop pack. Feed it a batch and it writes everything out in one pass, either with a prefix + counter or with original filenames preserved.
How it works
It's a straightforward loop over the batch dimension:
for i in range(images.shape[0]):
# ... pick a filename ...
pil_image.save(filepath)
Each image becomes a PIL image and gets written via Pillow, which guesses the file format from the extension. The naming logic has three branches, and this is where you need to pay attention:
original_filenameis empty (the default) → you getbatch_0000.png,batch_0001.png, …preserve_original_nameon,original_filenamea single string, batch of one → the exact original name, unchanged.preserve_original_nameon, single string, multi-image batch →name_0000.ext,name_0001.ext, …
The inputs that matter:
images- the batch to save. Required.filename_prefix- defaultbatch_. Only used in the fallback branch, so leave it alone unless counter names are fine.output_folder- default empty, which means the standard ComfyUI output directory (theoutput/folder next to your install). Anything non-empty is created on the fly and used verbatim, so you can point it at an absolute path anywhere on disk.original_filename- the surprise of this node. The schema types it as STRING, but the code checksisinstance(original_filename, list), and in practice you wire in the Loader'sfilenamesoutput. Feed it the list and each image gets its own original name back.preserve_original_name- default on.
The single output is saved_paths, the list of absolute paths of everything written. There's no preview - this is an output node, the end of the line.
Where people get burned
- Preservation is conditional. If
original_filenameis empty,preserve_original_namedoes nothing and you silently getbatch_0000.pngfiles. The toggle only matters when a name is actually flowing in. - Silent overwrites. Same-name files clobber each other with no warning. If your source has
photo.pngin two subfolders, the second wipes the first. - Extension roulette. Preserve a
.jpgname and you get a JPEG written from the RGB tensor; take the prefix path and you get PNGs. Both fine - just know the format follows the filename.
Install
Identical to the rest of the pack, because it's all one repo:
cd ComfyUI/custom_nodes
git clone https://github.com/cedarconnor/comfyui-BatchNameLoop
Restart ComfyUI, or grab it in ComfyUI Manager under "Batch Name Loop". No requirements.txt, no model downloads - Pillow, torch and numpy are already in your ComfyUI environment. The whole pack is MIT-licensed and a single commit, so temper your expectations around support; the node source is only ~30 lines if you want to know exactly what your files go through.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| filename_prefix | STRING | batch_ | — |
| output_folder | STRING | — | |
| original_filenameopt | STRING | — | |
| preserve_original_nameopt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| saved_paths | STRING | — |