Nodes/ComfyUI-KYNode/KY File/Folder Path
ComfyUI Node

KY File/Folder Path

Read whatever's sitting at a path, mid-graph

By yorkane·Created 2 years ago·Updated 6 months ago· 10
KY File/Folder Path
  • dummy_input
  • override_path
  • full_path
  • parent_dir
  • image
  • text
path
create_missing_folderfalse

A flexible little file-reading node: point it at a path and it figures out what's there and hands back the useful bits - the normalized absolute path, the parent directory, an actual IMAGE tensor if the path is an image file, or the raw text contents if it's a text file. One node instead of separate "load image" and "load text" nodes when you don't know in advance which one you'll need.

How it works

Type a path into path - relative, absolute, or with environment variables, per the node's own description. It normalizes that into full_path and reports parent_dir alongside it. Then, based on what's actually at that location, it returns either an image tensor (if the file is an image) or text (if it's a text file) - whichever doesn't apply comes back empty/None.

Two optional inputs are worth understanding. create_missing_folder will create the directory the path points to - but only if the path itself ends in a slash (/ or \), which is how the node distinguishes "this is a folder" from "this is a file that doesn't exist yet." dummy_input (typed *, accepts anything) is a classic ComfyUI trick: wire literally anything into it purely to force this node to re-execute when something upstream changes, since ComfyUI otherwise caches a node whose actual inputs haven't changed - useful if path itself is a static string but you want the read to happen fresh on each run. override_path lets you swap in a computed path from elsewhere in the graph without editing the path widget directly; it only takes priority when it's non-empty and not the literal string "*".

Installing it

ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/yorkane/ComfyUI-KYNode

Restart ComfyUI. No extra dependencies for basic file/image/text reading beyond what ComfyUI already ships.

Common issues

create_missing_folder only fires when your path literally ends in a slash - typing outputs/myfolder (no trailing slash) is read as a file named myfolder, not a directory, so the auto-create won't kick in. You need outputs/myfolder/ with the trailing character for that behavior to apply.

If both image and text come back empty, the path probably doesn't point at either an image or a recognized text file - or the file doesn't exist at all. Check the full_path output first; it shows you exactly what the node resolved your input to, which is the fastest way to catch a typo or a relative path that resolved somewhere unexpected.

The exact syntax for environment-variable expansion in path isn't documented beyond "supports environment variables" - if %VAR%-style or ${VAR}-style substitution isn't resolving the way you expect, fall back to a plain absolute path rather than guessing at the syntax.

And don't forget override_path silently wins over your typed path whenever it's set to anything other than empty or "*" - if you're editing the path widget and seeing no effect, check whether something upstream is feeding override_path and overriding it.

CategoryKYNode/files

Inputs (4)

NameTypeDefaultDescription
pathSTRING
create_missing_folderoptBOOLEANfalseCreate the directory only if it does not exist AND path ends with '/' or '\'.
dummy_inputopt*
override_pathopt*

Outputs (4)

NameTypeDescription
full_pathSTRING
parent_dirSTRING
imageIMAGE
textSTRING