is file
Is that path a file? The node that answers
- is file
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:
Trueonly when the path exists and is a regular file.- A directory returns
False, a nonexistent path returnsFalse. 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) -
Trueonly 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.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| is file | BOOLEAN | — |