Nodes/ComfyUI-YogurtNodes/Path Operator (Yogurt Nodes)
ComfyUI Node

Path Operator (Yogurt Nodes)

Path Math Without Opening a Terminal

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
Path Operator (Yogurt Nodes)
    • result
    operatorpath_join
    path_a
    path_b

    File paths show up all over ComfyUI - model folders, save directories, input images - and manipulating them is usually a fiddly, error-prone string job. YogurtPathOperator is a small utility that does path math for you: four operations, two path inputs, one result.

    • operator - pick the operation.
    • path_a - the primary path.
    • path_b - the second path, used by whichever operator you chose.

    Output: result, a single STRING.

    The four operations

    • path_join - glue path_a and path_b together with the right separator for your OS, no hand-typed slashes. This is the one you'll use daily, building models/loras/... style paths from parts.
    • relative - given path_a and path_b, give back the relative path from one to the other.
    • relative_to - the other direction of the same idea, expressed from path_b's perspective.
    • common_path - return the common prefix shared by both paths, which is handy when you need "the folder both of these live under."

    Because it's using proper path logic rather than string replacement, you don't fight separator issues between Windows and Linux - the node handles \ vs / for you, which alone is worth the install on a workflow you share across machines.

    Where it fits

    Any place you're composing or decomposing paths: building an output folder from a prefix and a date token, finding the relative path between an input image and your working directory, or resolving a common directory before a save node. It's the kind of node you wire once, then never think about again - which is the compliment these utilities deserve.

    Install

    Ships in ComfyUI-YogurtNodes. ComfyUI Manager → search ComfyUI-YogurtNodes → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
    cd ComfyUI-YogurtNodes
    pip install -r requirements.txt
    

    Restart ComfyUI; it's under "Yogurt Nodes" with the " (Yogurt Nodes)" suffix on the display name.

    One honest caveat: this node does path math, not path I/O. path_join will happily produce a path to a folder that doesn't exist, and common_path doesn't verify anything on disk. If you need directories created, pair it with the pack's YogurtCreateDirectory node; if you need to check files exist, use a glob or file-listing node instead.

    CategoryYogurtNodes/IO

    Inputs (3)

    NameTypeDefaultDescription
    operatorCOMBOpath_joinSelect the operation to apply to the two input paths.
    path_aSTRINGPrimary path input.
    path_bSTRINGSecondary path input used by the selected operator.

    Outputs (1)

    NameTypeDescription
    resultSTRING