From 06e94f0e2e8a6fd3145dc1c8a6befca19e8d6a09 Mon Sep 17 00:00:00 2001 From: andrewtvuong Date: Sun, 5 May 2024 19:33:01 -0700 Subject: [PATCH] Revert changes to folder_paths.py, changes to nodes.py instead https://github.com/comfyanonymous/ComfyUI/pull/3402\#issuecomment-2094914458 --- folder_paths.py | 6 +----- nodes.py | 7 +++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/folder_paths.py b/folder_paths.py index d13019c7c..489795002 100644 --- a/folder_paths.py +++ b/folder_paths.py @@ -242,13 +242,9 @@ def get_save_image_path(filename_prefix, output_dir, image_width=0, image_height input = input.replace("%height%", str(image_height)) return input - current_date = time.strftime("%Y-%m-%d") filename_prefix = compute_vars(filename_prefix, image_width, image_height) - if filename_prefix: - subfolder = os.path.dirname(os.path.normpath(filename_prefix)) - else: - subfolder = current_date + subfolder = os.path.dirname(os.path.normpath(filename_prefix)) filename = os.path.basename(os.path.normpath(filename_prefix)) full_output_folder = os.path.join(output_dir, subfolder) diff --git a/nodes.py b/nodes.py index acad256f8..72ce49268 100644 --- a/nodes.py +++ b/nodes.py @@ -1388,7 +1388,8 @@ class SaveImage: def INPUT_TYPES(s): return {"required": {"images": ("IMAGE", ), - "filename_prefix": ("STRING", {"default": "ComfyUI"})}, + "filename_prefix": ("STRING", {"default": "ComfyUI"}), + "organize_by_date": ("BOOLEAN", {"default": True, "label_on": "enable", "label_off": "disable"})}, "hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"}, } @@ -1399,8 +1400,10 @@ class SaveImage: CATEGORY = "image" - def save_images(self, images, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None): + def save_images(self, images, filename_prefix="ComfyUI", organize_by_date=True, prompt=None, extra_pnginfo=None): filename_prefix += self.prefix_append + if organize_by_date: + filename_prefix = time.strftime("%Y-%m-%d") + "/" + filename_prefix full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0]) results = list() for (batch_number, image) in enumerate(images):