ComfyUI Node

is file

Is that path a file? The node that answers

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

    Basic data handling: PathIsFile ("is file") tells you whether a path points at a regular file - not a directory, not a missing path, a file. Path in, BOOLEAN out. It's the more specific cousin of PathExists, and it's the check you actually want before you feed a path to any of this pack's loaders or PathGetSize.

    Here's the workflow where it earns its keep: you've globbed a folder with PathGlob or read a list of paths from a config file, and you're about to load each one. Before a PathLoadImageRGB or PathLoadStringFile runs, gate it on is file - you skip directories, skip dead entries, skip whatever junk got into the list, and only real files reach the loader. The loaders in this pack already handle missing files gracefully (they return an exists=False flag), but PathIsFile is how you avoid the empty-image dead-ends entirely and keep the graph honest.

    How it works

    It's a direct call to Python's os.path.isfile(path). The details:

    • True only when the path exists and is a regular file.
    • A directory returns False, a nonexistent path returns False. No error, no exception - this is a gentle check on purpose.
    • "Regular file" matters: symlinks are followed, so a symlink to a file counts as a file. On most systems you won't run into the distinction, but it's Python semantics, so that's what you get.

    Inputs and outputs

    • path (STRING, default "") - the path to test.
    • is file (BOOLEAN) - True only if the path exists and is a regular file.

    Installing it

    Part of Basic data handling, the dependency-free pack. ComfyUI Manager → search "Basic data handling" → install → restart, or:

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

    Restart after. No models, no pip.

    Gotchas

    Remember that False is ambiguous - it covers "it's a directory" and "it doesn't exist" in one answer. If you genuinely need to distinguish those two cases (say, to decide between creating a file vs. a folder), chain PathIsFile with PathIsDir or PathExists rather than assuming. And since it reads the disk live at execution time, a file deleted between the check and the load will still bite you - the check just narrows the odds. For most automation, it's the right guard: simple, correct, and it pairs perfectly with the stricter nodes in this pack that throw errors when handed a bad path.

    CategoryBasic/Path

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (1)

    NameTypeDescription
    is fileBOOLEAN