Path Dirname
The folder behind the file
- dirname
Path Basename gives you the file; Path Dirname gives you the folder. Feed it models/checkpoints/dreamshaper_8.safetensors and it hands back models/checkpoints. It's the complement to its sibling in the same pack, and it's what you reach for when the directory is the thing you actually need - not the filename sitting inside it.
Why would you need just the folder? Maybe you want to check the directory exists before saving into it, or build a sibling path by joining the dirname with a new filename. ComfyUI's core gives you almost no string plumbing for this, so these one-line os.path wrappers quietly fill a real gap.
How it works
The whole node is a single call to os.path.dirname(path) returned as a string. Pure textual splitting - it never touches the disk, doesn't care if the folder exists, and doesn't normalize anything about the path except what dirname inherently does.
The quirks are inherited from Python's os.path behavior:
- A bare filename with no separator (
dreamshaper_8.safetensors) returns an empty string - there's no folder in the path. - A path ending in a separator (
models/checkpoints/) returns the path minus the trailing separator, i.e.models/checkpoints. - The result uses your OS's native separators. On Windows you get backslashes, on Linux/macOS forward slashes.
Inputs and outputs
- path (STRING) - the full path to split. Default is empty.
- dirname (STRING) - the directory portion, ready to wire into anything that takes a string path.
The natural pairing: dirname out → Path Join (or Path Exists) in, to either build a new path in the same folder or verify the folder is actually there before you write into it. If you wanted the filename half instead, that's Path Basename.
Installing it
Same story as the rest of this pack - zero dependencies, no pip install, no model downloads. If you use ComfyUI Manager, search "path-util" and install from there. Otherwise:
cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-path-util
Restart ComfyUI after cloning and the nodes appear under the path-util category. There's no requirements.txt here, so nothing to conflict with your existing install - about as safe a custom-node install as exists.
Common issues
The empty-string result trips people up: you feed it a bare filename and get nothing, which looks like the node is broken when it's actually correct. Similarly, if you expected a trailing separator on the output, you won't get one - dirname strips it.
And a reminder that applies to the whole pack: these are string operations, not filesystem checks. dirname happily returns a folder that doesn't exist. If your workflow depends on the folder being real, run the output through Path Isdir and branch on the result rather than assuming.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dirname | STRING | — |