Nodes/ArtyClaw Comfy Nodes/String Stripper (Path & Ext)
ComfyUI Node

String Stripper (Path & Ext)

Get the Bare Model Name Out of a Full Path

By artyclaw·Created 5 months ago·Updated 5 months ago· 0
String Stripper (Path & Ext)
    • string_out
    string_in

    Here's a small annoyance every ComfyUI regular has hit: a loader hands you models/checkpoints/BeautifulMix_v2.1.safetensors and you need just BeautifulMix_v2.1 - for a filename, a sidecar lookup, or a conditional that switches on the model name. String Stripper (Path & Ext) is the node that does that one transformation, and it's exactly as boring and useful as it sounds.

    It's from artyclaw/artyclaw-comfy, and the class name (CheckpointNameStripper) doesn't match the display name ("String Stripper (Path & Ext)") - a reminder that this pack is a personal toolkit with the author's own naming baked in. The display name is the accurate one: it strips a path down to the filename, then strips the extension.

    How it works

    Three steps, no magic:

    1. Normalize backslashes to forward slashes, so Windows paths (models\checkpoints\foo.safetensors) and POSIX paths behave identically.
    2. Split on / and take the last segment - the filename.
    3. os.path.splitext on that to drop the extension.

    path/to/model.safetensorsmodel. C:/models/char_style.safetensorschar_style. Empty input returns an empty string rather than erroring, which keeps downstream nodes alive.

    Input and output

    One input, string_in - a plain single-line string. It's declared with forceInput in the source, meaning you're expected to wire it from another node (a checkpoint loader's output, a folder parser, a file selector) rather than hand-type it. One output, string_out, with the bare name.

    It's the kind of node you chain: Folder File Selector → CheckpointNameStripper → a text concat node that builds a save filename, or → a switch that routes on which model is loaded. Nothing here touches files itself - it's a pure string function.

    Install

    ComfyUI Manager → search ArtyClaw Comfy Nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/artyclaw/artyclaw-comfy
    

    Restart. Standard library only.

    Where people get burned

    The main gotcha is expectation mismatch: if you feed it something that isn't a path, like a bare model.safetensors, it still works (no slashes to strip, just the extension), but if you feed it a name with no extension at all, it returns it unchanged - nothing to strip. And it only strips the last extension, so model.v2.safetensorsmodel.v2, which is correct behavior for multi-dot names but easy to misread at a glance. There's also no option to keep the extension; if you need the full filename, this isn't the node. For a zero-config utility, it does exactly what it says and stays out of your way.

    CategoryCustom/String

    Inputs (1)

    NameTypeDefaultDescription
    string_inSTRINGInput string (e.g., path/to/model.safetensors)

    Outputs (1)

    NameTypeDescription
    string_outSTRING