Nodes/comfyui_imgtools/Path Splitter (rholdorf)
ComfyUI Node

Path Splitter (rholdorf)

The boring node that saves you ten minutes of string surgery

By rholdorf·Created 8 months ago·Updated 2 days ago· 0
Path Splitter (rholdorf)
    • directory
    • filename
    • stem
    path

    Sometimes the most useful node in a pack is the one that does almost nothing. Path Splitter takes a path string and splits it into directory, filename, and stem. That's it - no AI, no tensor math, no settings. It's the utility you reach for when a loader hands you a full path and the next node wants just the filename, or just the folder, or just the name without the extension.

    How it works

    Standard Python path splitting: os.path.dirname, os.path.basename, and os.path.splitext. Given /home/user/dataset/img004.png you get directory /home/user/dataset, filename img004.png, and stem img004. It respects whatever separators your OS uses, so a Windows path like C:\data\img.png splits the same way. Nothing clever, nothing surprising.

    Inputs and outputs

    Input: path (a STRING). Outputs: directory, filename, stem - all STRINGs.

    In a workflow

    The natural source is the pack's Load Images with Captions from Dir, which outputs a file_path for every loaded image. Split that and you can rebuild dataset-relative paths, construct filename_prefix values for the pack's Save Image with Caption, or drive any folder-parser node that wants just the folder. It also plays nicely with LoRA merger workflows if you want to manipulate saved-file names after a merge.

    Honestly, if you never build paths dynamically, you may never need it. But the moment you want to save outputs back into the same folder you loaded them from - same directory, new suffix - it turns an "ugh, string math" moment into two wires. Tiny, zero-risk, and it does exactly what the name says.

    Install

    Part of the small comfyui_imgtools pack by rholdorf. Install once, get all 11 nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/rholdorf/comfyui_imgtools
    

    Restart ComfyUI. Or search "rholdorf" in ComfyUI Manager. No build step, no extra dependencies - it's a few os calls on what ComfyUI already ships. Young, low-star solo pack: MIT, short readable code, no network calls, no model downloads. JS changes under web/ need only a browser refresh; Python changes need a restart.

    Categoryrholdorf/utils

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (3)

    NameTypeDescription
    directorySTRING
    filenameSTRING
    stemSTRING