Nodes/ComfyUI-KYNode/FilePath Analyzer
ComfyUI Node

FilePath Analyzer

Split a path into every piece you'd actually reuse

By yorkane·Created 2 years ago·Updated 6 months ago· 10
FilePath Analyzer
    • parent_dir
    • file_stem
    • file_extension
    • file_name
    • full_path
    file_pathfile.txt

    A plumbing node, and a genuinely useful one: feed it a file path as a string, and it hands back every piece you'd normally have to string-slice out yourself - the containing folder, the filename with and without its extension, the extension alone, and the path reassembled whole. The node's own description (written in Chinese, one of a few spots in this pack where the author's working language shows through) says exactly that: extract the parent directory, the filename without extension, the extension, the filename with extension, and the full path, from a given file path.

    Why you'd reach for this

    Any workflow that processes a batch of files and wants to preserve some relationship to the originals - saving a caption alongside an image under a matching name, building an output path that mirrors the input folder structure, logging which file a given result came from - needs these pieces. Rather than writing a one-off string-splitting expression every time, this node does it once, consistently, and hands you five ready-to-wire outputs.

    It pairs naturally with this pack's own KY_Load_Images_from_path (whose file_names output is exactly the kind of string you'd feed in here one at a time) or KY_ReadImage (whose single image_path input this node can help you construct, working the other direction).

    Inputs and outputs

    One required input: file_path, a plain STRING with the default "file.txt" - a reminder that this is pure string parsing, not a live file lookup; the path doesn't need to point at anything that actually exists on disk for this node to do its job.

    Five outputs, all STRING: parent_dir, file_stem (the name without its extension), file_extension, file_name (the name including its extension), and full_path.

    Installing it

    ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yorkane/ComfyUI-KYNode
    

    Restart ComfyUI. Pure string handling - nothing to download, no external calls.

    Common issues

    Because this node never touches the filesystem, it won't warn you if the path doesn't actually exist - it just parses the string as text. If a downstream node then fails trying to read a file that doesn't exist, the bug is in whatever produced or typed the file_path string, not in this node.

    Path-separator handling depends on the OS ComfyUI is actually running on. A Windows-style path (C:\folder\file.txt) parsed on a Linux server, or vice versa, can split unpredictably depending on how the underlying parsing handles the "wrong" separator for that platform - if parent_dir or file_stem come back looking mangled, check whether the path string's format actually matches the OS the node is running under, especially if you're pasting a path copied from a different machine.

    If you feed it a URL instead of a local file path, don't expect meaningful results from parent_dir - this is built for filesystem paths, and a URL's query string or fragment will likely end up folded into file_extension or file_name in a way that isn't what you want; strip a URL down to just its path portion first if that's genuinely what you're analyzing.

    CategoryKYNode/files

    Inputs (1)

    NameTypeDefaultDescription
    file_pathSTRINGfile.txt

    Outputs (5)

    NameTypeDescription
    parent_dirSTRING
    file_stemSTRING
    file_extensionSTRING
    file_nameSTRING
    full_pathSTRING