os.path.isdir
'is this a real folder?' before you write into it
- path_in
- isdir
"You can't save there, it's not a directory" is a classic ComfyUI facepalm - the saver node accepts the path, the run takes a while, and then it dies at the end because the folder doesn't exist or a filename collides with a directory. os.path.isdir is the five-second check that makes that failure a clean branch instead of a crash.
It's from the ovum/path/os.path family in comfy-ovum, and like its siblings it's a faithful wrapper over Python's os.path.isdir(). Behavior is the stdlib's behavior, full stop.
How it works
A simple predicate: does this path point at an existing directory? Returns a BOOLEAN (isdir). Path from either:
- path (STRING, required): the widget.
- path_in (PATHLIKE,STRING, optional): link-only; overrides the widget when connected.
One BOOLEAN out. Unlike the get* nodes, this one is safe on garbage: a missing path, a path that's actually a file, or a permissions error all just return False instead of throwing. That's the stdlib contract, and it's why predicates are the "check first" half of your workflow logic.
Where you'd use it
The obvious pattern is a pre-flight check before anything writes: wire the target output folder in, and if isdir is false, route around the write - or, in a scripted graph, raise a clear message instead of a cryptic late error. It's also handy for distinguishing "this path is a directory" from "this path is a file" when you're building file-dispatch logic, especially if you're feeding paths from the pack's Folder Paths node or from an Image List Loader that can point at either.
Pair it with os.path.isfile to build a three-way branch: directory → list it, file → process it, neither → error. That's a genuinely useful dispatch pattern for batch folders.
Installing it
Once per pack, standard:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Or ComfyUI Manager → "comfy-ovum" → Install → restart. No models to download, no extra dependencies for this node.
Gotchas
isdirfollows symlinks: a symlink pointing at a directory returnsTrue. If you specifically want to know whether the entry itself is a symlink, that's theos.path.islinknode.- On a path you don't have permission to stat, it returns
Falsesilently. It won't tell you why - if you're debugging a "my folder vanished" mystery, the console error from the write itself will be more informative. - It's a snapshot at execution time. If some other process is mid-creation, you can get
Falseright before the folder appears. For polling-style workflows, re-run or combine with the mtime/size nodes.
This is one of those boring nodes you only notice when you're missing it. Put it ahead of every saver that writes to a user-configurable folder and a whole class of "ran for twenty minutes and died" complaints disappears.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| path_inopt | PATHLIKE,STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| isdir | BOOLEAN | — |