ComfyUI Node

exists

Does that file actually exist? Stop guessing, wire it in

By StableLlama·Created about a year ago·Updated 4 days ago· 48
exists
    • exists
    path

    Basic data handling: PathExists ("exists") is the smallest useful node in this pack, and one of the easiest to overlook. It takes one path and answers one question: is there something at that location - file or directory - yes or no? No lists, no globs, no side effects. A single BOOLEAN out, one STRING in. It's the os.path.exists() you'd call in a script, dropped onto the graph.

    Why would you want that mid-workflow? Because ComfyUI workflows get built to run more than once. The moment you point a node at a file that may or may not be there - a LoRA you downloaded, a reference image your pipeline is supposed to pick up, a directory your save node is about to write into - you want the graph to react instead of silently erroring or producing a black image. Feed the exists output into any control-flow node (this same pack has a whole IF/ELSE section) and you can branch: load the file if it's there, skip it if it isn't.

    How it works

    Under the hood it's a one-liner: the node calls Python's os.path.exists(path) and returns the boolean. That's it. Nothing cached, nothing clever, and notably no special-casing for file versus directory - it returns True for both. If you need to know which one it is, that's what the sibling PathIsFile and PathIsDir nodes are for. Empty path? os.path.exists("") is False, so you get a clean "nope" rather than an error.

    Inputs and outputs that matter

    • path (STRING, default "") - the only input. Absolute paths are the safe choice, but relative ones work too and resolve against ComfyUI's current working directory (see PathGetCwd if you're unsure what that is).
    • exists (BOOLEAN) - the one output. Wire it into a boolean input or a control-flow node.

    Installing it

    This node ships in the Basic data handling pack, which has zero extra dependencies - it leans on numpy, torch, and Pillow that ComfyUI already ships. Easiest path: ComfyUI Manager, search "Basic data handling", install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Then restart ComfyUI. No model downloads, no pip install step.

    Common issues

    Not many, honestly - it's a tiny node. The two things that trip people up:

    • It doesn't tell you file vs. folder. If you're branching on "is this a usable file," pair it with PathIsFile rather than trusting exists alone.
    • Relative paths are relative to ComfyUI's cwd, which depends on how you launched it. If you're getting unexpected False on a path that "obviously exists," print the cwd via PathGetCwd and make your path absolute.

    It's the kind of node you install for a bigger pipeline and then find yourself reaching for everywhere. Cheap, obvious, and it removes a whole class of "why did that fail" debugging.

    CategoryBasic/Path

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (1)

    NameTypeDescription
    existsBOOLEAN