ComfyUI Node

File Exists

A true/false gate for your filesystem

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
File Exists
    • exists
    file_path

    "Does this file exist?" is a question you ask your filesystem constantly once you start automating ComfyUI, and PettyPaintFileExists is the node that asks it for you. Give it a file path, get back a BOOLEAN - true if the file is on disk, false if not. That's the whole thing, and like the pack's other filesystem utilities (EnsureDirectory, CountFiles), its value is in what you wire the boolean into.

    The pattern is a workflow gate. Check whether a render already exists before running a batch - if exists is true, skip the expensive generation and load the cached result instead. Verify a model or LoRA file is present before a sampler runs, so you fail fast with a readable message instead of a cryptic load error. Guard a save node's folder. Wire the boolean into the pack's PettyPaintPassThroughNode (the "kill switch" node) and you can cut whole branches of the graph based on what's on disk. It's the kind of tiny primitive that batch-and-pipeline people reach for constantly and one-off generators never notice.

    How it works

    It's a straight os.path.exists() call - the same check Python scripts do everywhere. The file_path input is forceInput, so it expects a path wired in from another node (a text node, a path builder, or the pack's own nodes that emit paths) rather than something you type. It also overrides IS_CHANGED to key on the path string, so ComfyUI re-evaluates the node when the path changes instead of caching a stale answer - important for the gate pattern, because a stale "file missing" that lingers after a file appears would silently break your skip logic.

    The inputs and outputs

    • file_path - STRING, forceInput, default empty.
    • Output: exists (BOOLEAN) - true when the file is there.

    Installing it

    It's part of the petty-paint pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mephisto83/petty-paint-comfyui-node
    

    Restart ComfyUI, or install via ComfyUI Manager searching "petty-paint-comfyui-node". Declared dependency: Flask==2.1.2, unused here.

    Common issues

    Two subtleties. First, this is a plain existence check - it doesn't test readability or whether the path is a file vs. a directory, so a directory path returns true too. If you need "is this a file, specifically," this node won't tell you. Second, the path semantics are yours to own: relative paths resolve against wherever ComfyUI's working directory is, which is usually not where you think, so absolute paths are the reliable choice. And the empty default can be a silent trap - wire the path from something real, or you'll get a confident false for a file you're certain exists.

    CategoryPettyPaint

    Inputs (1)

    NameTypeDefaultDescription
    file_pathSTRING

    Outputs (1)

    NameTypeDescription
    existsBOOLEAN