Nodes/ComfyUI Batch Name Loop/Batch Image Saver
ComfyUI Node

Batch Image Saver

Keep your filenames through a batch, mostly

By cedarconnor·Created about a year ago·Updated about a year ago· 1
Batch Image Saver
  • images
  • saved_paths
filename_prefixbatch_
output_folder
original_filename
preserve_original_nametrue

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_filename is empty (the default) → you get batch_0000.png, batch_0001.png, …
  • preserve_original_name on, original_filename a single string, batch of one → the exact original name, unchanged.
  • preserve_original_name on, single string, multi-image batch → name_0000.ext, name_0001.ext, …

The inputs that matter:

  • images - the batch to save. Required.
  • filename_prefix - default batch_. 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 (the output/ 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 checks isinstance(original_filename, list), and in practice you wire in the Loader's filenames output. 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_filename is empty, preserve_original_name does nothing and you silently get batch_0000.png files. 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.png in two subfolders, the second wipes the first.
  • Extension roulette. Preserve a .jpg name 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.

CategoryBatchNameLoop

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
filename_prefixSTRINGbatch_
output_folderSTRING
original_filenameoptSTRING
preserve_original_nameoptBOOLEANtrue

Outputs (1)

NameTypeDescription
saved_pathsSTRING