os.path.split
One node instead of dirname+basename
- path_in
- head
- tail
Half the time you need the directory of a file, half the time you need the filename, and usually you need both. Other packs make you wire up two nodes for that. os.path.split gives you both halves of a path in one shot: the (head, tail) pair that Python's os.path.split() returns - the folder path and the final component, whatever it is.
It's from the ovum/path/os.path family in comfy-ovum, sfinktah's utility pack, and it's a straight wrapper over the stdlib function. No surprises.
How it works
Splits a path into its directory and its last component, returning two STRING outputs:
- head: everything up to the last separator.
C:\renders\frames\→C:\renders - tail: the final component.
frame_0072.png
Path from either:
- path (STRING, required): the widget.
- path_in (PATHLIKE,STRING, optional): link-only; overrides the widget when connected.
The split is purely string-based - head + a separator + tail reconstructs the original (mostly; edge cases like trailing slashes aside, that's the identity). No filesystem access, so it's safe on paths that don't exist.
Where you'd use it
This is the workhorse for output naming. The classic move: take a loader's file path, split off the tail, feed the tail into a string-format node, and rebuild an output filename like {tail}_hires.png - or split off the head and use it as the base directory for where outputs go. Because head and tail are separate outputs, you can route them to different consumers without string surgery.
It pairs with the rest of the family: os.path.splitext for separating extension from name (that's the one for name.png → name + .png), and os.path.join for putting pieces back together. Split → modify → join is the canonical pipeline for renaming or relocating outputs.
Installing it
Standard pack install, once:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Or ComfyUI Manager → "comfy-ovum" → Install → restart. No models, no extra deps.
Gotchas
- Two outputs means two wires. If you only need the directory, you still have the tail dangling - that's fine, unconnected outputs don't hurt, but Comfy's "mute unused" habits might make you reach for the
os.path.dirnamenode in this same pack instead if you truly only ever want one half. - Trailing-slash behavior.
spliton a path that ends with a separator treats the previous component as the tail.C:\renders\→ headC:\, tailrenders. This matches Python exactly and trips people up exactly once. - It's not
splitext. Split breaks at the last folder boundary; the extension stays glued to the filename. If you wantnamevs.png, that's the separateos.path.splitextnode.
For "give me the folder and the filename separately," this is the node. It's boring, it's two outputs instead of one, and it's exactly what the path manipulation half of your workflow keeps needing.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| path_inopt | PATHLIKE,STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| head | STRING | — |
| tail | STRING | — |