ComfyUI Node

Split Path

Pull the drive, folder, filename, and extension out of a path string

By 807502278·Created 2 years ago·Updated 11 months ago· 20
Split Path
    • drive
    • path
    • file_name
    • file_ext
    • file_str
    • is_file
    • is_path
    • is_file_or_path
    Path

    Split Path takes one path string and hands you back every piece of it, separately, as clean outputs you can wire wherever you need. Feed it something like D:\comfyui\output\render_042.png and out comes the drive letter, the folder path, the filename, the extension, the filename-plus-extension together, and three booleans telling you whether that path currently points to a file, a folder, or either one at all on disk.

    The inputs and outputs that matter

    That last part is the detail worth sitting with: is_file, is_path, and is_file_or_path aren't just parsing the string - they check the actual filesystem at the moment the node runs. So this node does double duty as a path splitter and a lightweight existence check, which is exactly what you want when a workflow needs to branch on "does this file already exist" before deciding whether to regenerate something, or needs to validate a user-supplied path before trying to load from it.

    The full output list: drive, path, file_name, file_ext, file_str (name plus extension together), is_file, is_path, is_file_or_path. One input: Path, a plain string field. Wire in a full path - from a Save Image node's output, a Split_Path earlier in the graph, or just typed - and grab whichever piece you need downstream.

    One thing worth clearing up if the tooltip confuses you: the description text attached to this node mentions deleting files if a "Deletes" toggle is enabled. Ignore that - there's no delete option in this node's actual input list, just the single Path field. That text appears to be carried over from a different node in the same pack, del_file, which genuinely does check-and-optionally-delete a file. Split_Path itself only looks; it never touches anything on disk.

    Installing it

    One pack, one install, every WJNode node comes with it. ComfyUI Manager: search "ComfyUI-WJNodes," install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/807502278/ComfyUI-WJNodes.git
    

    It's under WJNode → Path in the search after restart. Nothing to download, nothing extra to pip install for this one - it's pure Python path handling plus a filesystem check, both things a stock ComfyUI environment already covers.

    Where it's genuinely useful

    Pair it with Save_Image_To_Path from the same pack: that node writes to a fixed location and hands you the PATH string back, and Split_Path is the natural next node if you want to log just the filename, branch on the extension, or confirm the write landed before continuing. It's also a nice sanity check in front of anything that reads from a user-typed path - run it through Split_Path first, check is_file before you try to load it, and you turn a confusing "file not found" crash three nodes downstream into a clear signal right where the path enters your graph.

    CategoryWJNode/Path

    Inputs (1)

    NameTypeDefaultDescription
    PathSTRING

    Outputs (8)

    NameTypeDescription
    driveSTRING
    pathSTRING
    file_nameSTRING
    file_extSTRING
    file_strSTRING
    is_fileBOOLEAN
    is_pathBOOLEAN
    is_file_or_pathBOOLEAN