Path Info
Take a file path apart without the regex
- path
- filename
- directory
The moment you start automating around saved images, you'll need to pick a filename apart from its path - the folder it's in, the name without the extension, the full path - and in ComfyUI that usually means hand-rolling string nodes and praying. NNPathInfo is the utility that does it in one step: feed it a path, get directory, filename, and path back out as separate strings.
What it is
NNPathInfo is a string-splitting utility node from the bandifiu/ComfyUI-NN-custom-nodes pack. Per the README: "Extracts information from a file path and separates it into directory, filename, and path components. Useful for workflows that need to manipulate saved image paths or process generated files." It pairs naturally with the pack's NNImageSaver, whose files output is a list of paths.
How it works
The mechanics are standard path handling. Give it a path and it splits it:
pathoutput - the input path, minus the file extension if you've asked for that (see below).filenameoutput - just the basename (the last component).directoryoutput - everything before the basename.
The two behavioral knobs:
index- for picking one item out of a list of paths. The node'spathinput accepts either a single string or a list; if it's a list,indexselects which element (clamped to the last one if the index is out of range). That's what makes it a drop-in after a batch saver, whosefilesoutput is a list.extension- default off. When off, the extension is stripped from both thepathandfilenameoutputs (sorender_0001.png→render_0001). Flip it on if you actually want the extension kept.
Everything is a plain STRING output - no hidden type magic - so the results wire straight into filename builders, show-text nodes, or downstream file-processing nodes.
The inputs
path- a string, or a list of strings (in which caseindexpicks the one).index- list index, default 0.extension- keep the file extension, default off.
Outputs: path, filename, directory - all STRING.
When to reach for it
The canonical wiring is NNImageSaver → NNPathInfo: the saver emits the list of saved files, and Path Info breaks each into a usable filename and folder so you can log, rename, or feed the result into something that needs a path component. It's also the right tool whenever a node gives you a full path and you only want the name - a folder loader, a batch image loader with a path output, that sort of thing. It's plumbing, and like most plumbing it's boring until the moment you need it, at which point it saves you from writing string-split logic in a node that has no business doing string math.
Installing
Part of bandifiu/ComfyUI-NN-custom-nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/bandifiu/ComfyUI-NN-custom-nodes
Restart ComfyUI (or Manager → "NN-custom-nodes"). Deps: torch, numpy, pillow - nothing else. GPL-3.0, V3 backend API.
The subtle thing to remember is the extension default: off means "strip the extension," which is what you want for most downstream filename use but not if you're reconstructing a path to actually open the file. Also, index clamps rather than errors - if you pass an index past the end of the list you get the last element, not an error, which is a quiet behavior to know about when a list comes out shorter than you expected.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| index | INT | 0 | — |
| extension | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| path | STRING | — |
| filename | STRING | — |
| directory | STRING | — |