ComfyUI Node

Path Info

Take a file path apart without the regex

By bandifiu·Created about a month ago·Updated about a month ago· 0
Path Info
    • path
    • filename
    • directory
    path
    index0
    extensionfalse

    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:

    • path output - the input path, minus the file extension if you've asked for that (see below).
    • filename output - just the basename (the last component).
    • directory output - everything before the basename.

    The two behavioral knobs:

    • index - for picking one item out of a list of paths. The node's path input accepts either a single string or a list; if it's a list, index selects 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, whose files output is a list.
    • extension - default off. When off, the extension is stripped from both the path and filename outputs (so render_0001.pngrender_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 case index picks 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 NNImageSaverNNPathInfo: 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.

    CategoryNN

    Inputs (3)

    NameTypeDefaultDescription
    pathSTRING
    indexINT0
    extensionBOOLEANfalse

    Outputs (3)

    NameTypeDescription
    pathSTRING
    filenameSTRING
    directorySTRING