From 582df5551b0c1029dfbc4384642f39eda6e6e304 Mon Sep 17 00:00:00 2001 From: 1lch2 <1lch2@163.com> Date: Mon, 25 May 2026 17:38:05 +0800 Subject: [PATCH] fix: handle trailing slash in filename_prefix When prefix ends with '/' or '\' (e.g. "comfy-txt2img/"), append default filename "ComfyUI" so it's treated as a subdirectory path rather than a bare filename. --- nodes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nodes.py b/nodes.py index ac9360f..fca3608 100644 --- a/nodes.py +++ b/nodes.py @@ -49,6 +49,11 @@ class SaveImageAsSDWebUI: CATEGORY = "image" def save_images(self, images, seed, filename_prefix="ComfyUI", image_format="png", quality=100, prompt=None, extra_pnginfo=None): + # If prefix ends with a path separator (e.g. "comfy-txt2img/"), + # treat it as a directory and append default filename "ComfyUI". + if filename_prefix.endswith('/') or filename_prefix.endswith('\\'): + filename_prefix = filename_prefix + "ComfyUI" + full_output_folder, filename, counter, subfolder, _ = folder_paths.get_save_image_path( filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0] )