Nodes/ComfyUI-YogurtNodes/Create Parent Directory (Yogurt Nodes)
ComfyUI Node

Create Parent Directory (Yogurt Nodes)

One input, one output, and a footgun hidden in the name

By yogurt7771·Created 2 years ago·Updated 4 days ago· 1
Create Parent Directory (Yogurt Nodes)
    • path
    path

    Create Parent Directory is the kind of node you don't think about until your save node starts throwing "No such file or directory" at 3am. It takes a path string, makes sure the parent directory of that path exists, and returns the original path. That's the entire job, and most of the time that's exactly what you want before you write a file into a folder that doesn't exist yet.

    The footgun is right there in the name: it creates the parent, not the path you give it. Feed it output/renders/scene_01/frame.png and it creates output/renders/scene_01/, because the file is the last segment. Feed it output/renders/scene_01/ and it happily creates only output/renders/. The sibling Create Directory node in the same pack does the opposite - it makes the directory you actually name. Mixing the two up is the most common way people end up with one-level-shallow folders and files landing somewhere they didn't expect.

    How it works

    Under the hood it's a one-liner: Path(path).parent.mkdir(parents=True, exist_ok=True). The parents=True means it creates the whole chain - a/b/c parents get made even if a doesn't exist yet - and exist_ok=True means it won't error if the folder is already there. Then it returns your original path untouched. Note the leading path is relative to wherever ComfyUI's process runs (typically the ComfyUI install dir), not your input folder, so absolute paths are safer if your graph does path juggling.

    The only input

    • path - the full path whose parent should exist. Output is the same string, which is what makes this node pleasant to chain: you can wire path straight into a save node, safe in the knowledge that the directory's been created on the way through.

    When you'd reach for it

    • Before a Save-anything / output writer node that doesn't create its own directories.
    • In batch workflows where an iteration count or a dynamic filename builds a per-run folder - the mkdir runs each pass, and exist_ok=True makes that idempotent and cheap.
    • As a one-time "make sure this tree exists" bootstrap node at the start of a graph.

    Install

    It ships with ComfyUI-YogurtNodes, so it comes along when you install the pack:

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

    Or grab it via ComfyUI Manager (search "YogurtNodes") and restart. It shows up under "Yogurt Nodes" → IO, alongside the pack's Create Directory, Save * Bridge, and other path utilities.

    Common issues

    • "It created the wrong folder" - read the name again: parent only. Want the exact directory created? Use YogurtCreateDirectory.
    • "Files went to the wrong place" - relative paths resolve against ComfyUI's working directory, not your output folder. Use an absolute path if you're fighting this.
    • Nothing visibly happens - that's normal. It's a side-effect node; the output is just the path string so you can keep the chain going.

    Thin, but it removes a whole class of "directory does not exist" failures. Keep it next to your save nodes and you'll forget it's there - which is the goal.

    CategoryYogurtNodes/IO

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (1)

    NameTypeDescription
    pathSTRING