Path Parser
Tear a file path apart without regex
- directory
- filename
- extension
You load a workflow that gives you a full path - C:\workspace\hello.png - and what you actually want is the directory to feed a save node, or the filename stem to build a new name. Slicing that string by hand is where everyone introduces a bug. Path Parser splits a path into its three useful pieces - directory, filename, extension - with proper path handling instead of string surgery.
It's the forward half of the pack's Path Parser ↔ Path Joiner round-trip: you can tear a path apart, swap the extension, and join it back together without ever hand-editing a string.
How it works
It strips whitespace, normalizes separators with os.path.normpath (so a Windows path parsed on Linux still makes sense), then uses os.path.split and os.path.splitext to carve it up. The directory keeps a trailing separator, the extension keeps its leading dot, and the filename comes back without either. An empty input returns three empty strings instead of crashing.
Inputs and outputs
- path - the full path string.
Outputs:
- directory - e.g.
C:\workspace\ - filename - e.g.
hello(no extension) - extension - e.g.
.png(with dot)
Install
Standard pack install - ComfyUI Manager (search "ComfyUI-AutoFlow") or:
cd ComfyUI/custom_nodes
git clone https://github.com/ZXL-Xinram/ComfyUI-AutoFlow
Restart after. Pure stdlib; no dependencies.
Where people get burned
- The trailing separator. The directory output ends with a separator by design, so it round-trips cleanly into Path Joiner. If you feed it into something that expects a bare folder path, strip the separator - or just run it through Path Joiner and stop worrying.
- Extensions are split at the last dot.
archive.tar.gz→ filenamearchive.tar, extension.gz. That's standardsplitextbehavior, but it surprises people once. - It doesn't touch the filesystem. No existence check, no absolute-path resolution. If the path is a relative one, that's what you get back. Path Validator is the node for "does this actually exist."
This is a tiny utility, and it's honest about being one. Where it earns its keep: dynamic save prefixes, batch renaming, and any workflow where a filename built from parts needs to be inspected or rebuilt. Pair it with String Formatter and you've got the whole "build a good filename" story.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| directory | STRING | — |
| filename | STRING | — |
| extension | STRING | — |