From a34689b27c842b792cb0fc8011ac5fe1d6ebe8d8 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 11 Nov 2025 09:56:15 -0300 Subject: [PATCH] [Added] Nodes to get the ComfyUI input/output path Might be contributed to ComfyUI-basic_data_handling --- src/nodes/nodes_img.py | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/nodes/nodes_img.py b/src/nodes/nodes_img.py index 53a0cf9..7260803 100644 --- a/src/nodes/nodes_img.py +++ b/src/nodes/nodes_img.py @@ -10,6 +10,7 @@ from collections import defaultdict from copy import deepcopy import csv +from inspect import cleandoc import numpy as np import os from pathlib import Path @@ -55,6 +56,19 @@ try: from server import PromptServer except ModuleNotFoundError: PromptServer = None +try: + from comfy.comfy_types.node_typing import IO, ComfyNodeABC +except ModuleNotFoundError: + class IO: + BOOLEAN = "BOOLEAN" + INT = "INT" + FLOAT = "FLOAT" + STRING = "STRING" + NUMBER = "FLOAT,INT" + IMAGE = "IMAGE" + MASK = "MASK" + ANY = "*" + ComfyNodeABC = object logger = main_logger BASE_CATEGORY = "image" @@ -2302,3 +2316,47 @@ class ImageWithTextLabel: # Stack the processed images back into a single tensor return (torch.cat(output_images, dim=0),) + + +class InputDir(ComfyNodeABC): + """ + Returns the ComfyUI input path. + + This is where input images are usually stored when using ComfyUI + """ + @classmethod + def INPUT_TYPES(cls): + return {} + + RETURN_TYPES = (IO.STRING,) + RETURN_NAMES = ("input_path",) + CATEGORY = "Basic/Path" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "execute" + UNIQUE_NAME = "SET_InputDir" + DISPLAY_NAME = "Get ComfyUI Input Path" + + def execute(self) -> tuple[str]: + return (get_input_directory(),) + + +class OutputDir(ComfyNodeABC): + """ + Returns the ComfyUI output path. + + This is where output images are usually stored when using ComfyUI + """ + @classmethod + def INPUT_TYPES(cls): + return {} + + RETURN_TYPES = (IO.STRING,) + RETURN_NAMES = ("output_path",) + CATEGORY = "Basic/Path" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "execute" + UNIQUE_NAME = "SET_OutputDir" + DISPLAY_NAME = "Get ComfyUI Output Path" + + def execute(self) -> tuple[str]: + return (get_output_directory(),)