Nodes/RuiquNodes for ComfyUI/String Get Stem From Path
ComfyUI Node

String Get Stem From Path

Pull the clean filename out of a full path

By ruiqutech·Created 2 years ago·Updated 2 years ago· 0
String Get Stem From Path
    • stem
    path

    This one does exactly one thing: hand it a path, it hands back the filename with the directory and the extension stripped off. /models/checkpoints/myCheckpoint_v3.safetensors in, myCheckpoint_v3 out. It's the kind of tiny utility you don't think you need until you're building a workflow that has to name something based on what it just processed - labeling an output after the source image, tagging a batch run with the checkpoint that produced it, that sort of thing - and suddenly you're staring at a full path string with nothing built-in to clean it up.

    How it works

    "Stem" is Python's term for it - pathlib.Path(path).stem does exactly this, and the node's name and behavior line up closely enough that it's clearly doing the same thing under the hood. Two things follow from that, and both matter more than they look:

    It only strips the last extension. Feed it render.tar.gz and you get render.tar back, not render - the second dot doesn't count as part of the extension the way you might expect. Rare in image/video workflows, but it'll bite you the one time it comes up.

    It splits on path separators, and that's the one worth watching on comfy.icu specifically: the executor runs Linux, so it's parsing POSIX-style paths with forward slashes. If a string with Windows-style backslashes (C:\Users\you\image.png) ends up in the path input - easy to happen if it's coming from a local tool or a hand-typed value - a POSIX parser won't recognize the backslashes as separators at all, and you'll get the whole thing back instead of just the filename. Keep the strings you feed this node in forward-slash form and you won't hit it.

    The inputs and outputs that matter

    There's exactly one of each, which is the whole appeal:

    • path - a plain string, default empty. Any path or filename works; it doesn't need to point at a file that actually exists, it's just parsing the text.
    • stem - the output. Wire it into whatever needs the clean name: a text concatenation node building a filename prefix, a label on a Save Image node, a caption, anywhere you want "the name of the thing" without the clutter around it.

    How to install it

    ComfyUI Manager: search RuiquNodes for ComfyUI. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ruiqutech/ComfyUI-RuiquNodes
    

    Restart ComfyUI. No models, and going by the README nothing beyond the Python standard library either - this is a string-parsing node, so the install is instant with no download wait.

    Where people get burned

    The pack's README doesn't mention StringPathStem by name at all - its three sentences are entirely about a different set of nodes (EvaluateMultiple1/EvaluateMultiple3, which execute arbitrary Python), so what's written above comes from the node's own inputs and outputs, not from documentation that doesn't exist. Worth a quick look at what else that folder installs, since any node pack runs with full Python access once ComfyUI loads it.

    Practically, the two things that trip people up are the ones above: a double extension giving you more than you expected, and a Windows-formatted path not splitting the way it would on your own machine. If stem ever comes back looking identical to what you put in, that second one is almost always why - check for backslashes before you assume the node is broken.

    Categoryruiqu/string

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (1)

    NameTypeDescription
    stemSTRING