Nodes/CMK Flow/CMK SourcePathInfo
ComfyUI Node

CMK SourcePathInfo

Two string outputs, and one of them lies about its name

By CMKFlow·Created 3 months ago·Updated a day ago· 6
CMK SourcePathInfo
    • source_file
    • source_path
    ◄source_path—►

    CMK SourcePathInfo is the smallest node in the pack, and it exists because of one genuinely annoying thing about ComfyUI: a file path arrives as a string, and then you need to take it apart. You want the filename for a Save node's prefix, and the folder for a log line or a note. In plain ComfyUI you either retype both by hand or add a small custom node. This is that small custom node.

    It sits in CMK/Toolbox/I-O, which matters for how you read the whole pack. CMK Flow splits into two products: the closed -Pipe- ecosystem (the guided loader → sampler → post-process chain) and the Toolbox, a bag of free-standing utility nodes you can drop into any graph, CMK or not. SourcePathInfo is Toolbox. It shares nothing with the pipes and works fine on its own.

    How it works

    Two lines of Python. os.path.basename() on the input, os.path.dirname() on the input, done.

    source_file = os.path.basename(source_path)
    source_dir  = os.path.dirname(source_path)
    return (source_file, source_dir)
    

    No file is opened, nothing is validated against disk, and no path is normalised. If you feed it input/faces/me.png you get me.png and input/faces. If you feed it garbage you get garbage back, quietly. That is the correct behaviour for a plumbing node - it is string maths, not a file loader - but it means this node will never tell you a file is missing. Something upstream has to have actually resolved the path for it.

    Inputs and outputs

    There is exactly one input, source_path (STRING), and it is declared with forceInput. That means you cannot type a path into a widget on this node - you must wire a string in from somewhere. The usual source in a CMK graph is the image_file output of CMK Image File Loader, or the image_file output of CMK Load Image, both of which emit nothing but a path reference. This is the intended pairing: load the reference cheaply, inspect the path, and only decode pixels where you actually need them.

    Two outputs come back:

    • source_file - the basename. This is the one you actually use. Wire it into a filename_prefix, into a text note, into a filename-building string concat, or into a watermark/label field.
    • source_path - the directory. Note the name. The input is called source_path and holds a file; the output is called source_path and holds a folder. If you assumed the output was an echo of the input you are about to discover otherwise, usually by watching a Save node spit out a filename with slashes in it.

    That naming collision is the one real trap here, and there are no tooltips in the schema to rescue you. File it under "read the two-line source before believing the label."

    Install

    Via ComfyUI Manager: search CMK Flow and install the entry from publisher cmkflow (registry package cmk-flow), then restart ComfyUI. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/CMKFlow/cmk_nodes
    python3 custom_nodes/cmk_nodes/scripts/install_cmk_requirements.py
    

    That second command is not optional with a git clone - CMK never runs pip on its own. It finds the Python environment ComfyUI is actually using, installs requirements.txt, and prints CMK dependency check: OK when it worked. This node itself needs none of those packages, but the pack is loaded as a unit, so a broken insightface or onnxruntime install will keep the whole thing from registering.

    Common issues

    • The input socket won't accept typing. Correct - forceInput. Add a PrimitiveString or a text node upstream if you want to type a path by hand.
    • Windows paths. The node uses os.path, so on Windows you get backslashes and source_file still works, but any string you hand to something expecting POSIX separators will not.
    • Empty output. An empty string in gives two empty strings out with no error. Check upstream first.
    CategoryCMK/Toolbox/I-O

    Inputs (1)

    NameTypeDefaultDescription
    source_pathSTRING—

    Outputs (2)

    NameTypeDescription
    source_fileSTRING—
    source_pathSTRING—