split
Pull the folder and the filename apart
- directory
- filename
When a node has a one-word display name - just "split" - you can usually guess the whole deal. Give it a path like /output/frames/scene_003.png, and it hands back the directory (/output/frames) and the filename (scene_003.png) as two separate strings. That's the entire feature, and it's the load-bearing step in a lot of "save next to the input" workflows.
The reason you want it broken apart is that once directory and filename are separate strings you can rebuild paths flexibly: keep the same folder but swap the file, or keep the file and point it at a different directory. String nodes can do this with split on /, but that's fragile - Windows separators, trailing slashes, and drive letters all break naive string splitting. This uses os.path.split(), which is platform-aware and knows how to handle all of it. Same result, no footguns.
How it works
It's a straight passthrough to os.path.split(). Worth internalizing two Python behaviors so you're not surprised:
- A trailing slash means the "filename" part is empty (
"/a/b/"→("/a/b", "")). - A bare filename with no directory returns an empty directory string (
"scene_003.png"→("", "scene_003.png")).
Both are correct os.path behavior; neither is a bug, but they explain a few "why is this string empty" moments.
Inputs and outputs
One input, path (default empty string). Two outputs:
directory- everything up to the last separator.filename- the last path component.
Wire directory into a PathJoin or a save node, and filename into a PathSplitExt if you then want the stem without the extension. The two nodes compose nicely: split → splitext is the standard "folder + base name" pipeline.
Installing it
Part of the Basic data handling pack by StableLlama:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI, or grab it via ComfyUI Manager (search "Basic data handling"). Zero dependencies, no downloads - installing it can't conflict with anything, which is the pack's whole pitch.
Gotchas
- It's pure string work: the path doesn't need to exist, and the node won't check.
- Don't confuse this with
PathSplitExt(the "splitext" node) - that one splits the extension off the filename. Split splits at the last slash; splitext splits at the last dot. Different axes, and you'll reach for both within the same workflow.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| directory | STRING | — |
| filename | STRING | — |