ComfyUI Node

Path Isdir

'is this actually a folder?'

By kale4eat·Created 2 years ago·Updated 2 years ago· 0
Path Isdir
    • isdir
    path

    Path Exists will happily tell you "yes, something is at that path" when that something is a file you were hoping was a folder. Path Isdir is the node that refuses to be fooled: it only returns true when the path points to an actual directory. If you're building workflows that save output into folders, or check that a directory exists before dumping files into it, this is the check you actually want.

    It's one of three boolean "is it real and what kind" nodes in this pack, sitting between the looser Path Exists (anything at all) and Path Isfile (specifically a file). If your workflow's logic cares about the type of thing at a path, these three are your vocabulary.

    How it works

    One call to os.path.isdir(path), returned as a boolean. The rules:

    • true only for directories that exist.
    • false for files, for missing paths, and for empty strings.
    • Symlinks count as directories if they point at one - isdir follows the link.

    Inputs and outputs

    • path (STRING, default empty) - the path to test.
    • isdir (BOOLEAN) - the answer.

    Like the other boolean nodes in this pack, the output needs a destination: wire it into a Switch/If node to branch the graph, feed it to a node that accepts a boolean, or inspect it on a Primitive node while debugging. A natural pattern is checking a folder exists before a Save node writes into it - if isdir comes back false, branch to a node that creates the folder instead of failing silently later.

    Installing it

    Dependency-free, like the rest of the pack. No pip step, no model files, nothing to conflict with. Through ComfyUI Manager, search "path-util" and install; or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kale4eat/ComfyUI-path-util
    

    Restart ComfyUI and the path-util category shows up in the node list.

    Common issues

    The main footgun is the same one that hits all the boolean checks here: a relative path that's being resolved against ComfyUI's working directory, not wherever you think the folder is. When isdir returns false for a folder you can see in your file browser, absolutize the path first (Path Abspath) or double-check the string hasn't got a stray ~ or unexpanded variable in it.

    And remember the flip side: isdir is specific. It's false for files, which is exactly what you want when the question is "can I save a directory tree here," but if you catch yourself wanting "is this any kind of existing thing," that's Path Exists' job, not this node's.

    Categorypath-util

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (1)

    NameTypeDescription
    isdirBOOLEAN