Nodes/DJZ-Nodes/Project File Path Generator
ComfyUI Node

Project File Path Generator

Build clean, sanitized output paths without the backslash lottery

By MushroomFleet·Created 2 years ago·Updated 5 months ago· 78
Project File Path Generator
    • STRING
    rootoutput
    project_nameMyProject
    subfolderimages
    filenameimage
    separatorauto

    Every serious ComfyUI setup eventually hits the same wall: you're generating thousands of images and want them organized into output/ProjectName/images/..., but hand-typing paths into save nodes gets inconsistent fast - one workflow uses /, another \, and nothing matches. ProjectFilePathNode is a tiny utility that assembles a path from four parts and sanitizes the hell out of it, so every file lands in a predictable place. It's boring, and boring is exactly what you want from a path node.

    How it works

    You give it root, project_name, subfolder, and filename, and it joins them into one path string. The separator handling is the smart part: auto uses your OS's native separator (/ on Linux/Mac, \ on Windows), or you can force forward_slash or backslash - which matters more than it sounds when you're building paths that will be handed to tools with strong opinions about separators.

    What makes it worth installing over just typing a string: it sanitizes every component. It strips .. (so no path traversal sneaks in from a prompt string), removes unsafe filename characters like < > : " | ? *, replaces spaces with underscores, and strips .txt-style extensions off the filename. So "My Project", "episode:2" becomes My_Project and episode2 - no surprise broken paths later.

    The output

    One STRING, the fully joined path. It doesn't create folders and it doesn't write files - it generates a path for other nodes to consume. Wire it into SaveText's file input, a save-image node, or any file-path string input in your graph. IS_CHANGED always fires, so the path refreshes on every run even if nothing changed.

    Installing

    It's part of the DJZ-Nodes pack from Drift Johnson (MushroomFleet):

    cd ComfyUI/custom_nodes
    git clone https://github.com/MushroomFleet/DJZ-Nodes
    cd DJZ-Nodes
    pip install -r requirements.txt
    

    Or search "DJZ-Nodes" in ComfyUI Manager. Zero extra dependencies - pure os.path work.

    Where it slots in

    A common pattern: ProjectFilePathNodeSaveText, so every run appends the prompt to output/MyProject/logs/prompts.txt. Or chain a few with different subfolders to build a parallel directory structure. It pairs naturally with the pack's other file nodes (SaveText, LoadTextDirectory).

    Honest caveats

    It's a path builder, not a path resolver - it won't tell you if the folder exists. The root default is the literal string "output", so if you want the full ComfyUI output directory you'll typically wire in something like folder_paths.get_output_directory() from another node or type the absolute path. And remember: since spaces get replaced with underscores, don't fight it - name your projects in a filename-friendly way and let it do the rest.

    Categoryfile_management

    Inputs (5)

    NameTypeDefaultDescription
    rootSTRINGoutput
    project_nameSTRINGMyProject
    subfolderSTRINGimages
    filenameSTRINGimage
    separatoroptCOMBOauto3 options: auto, forward_slash, backslash

    Outputs (1)

    NameTypeDescription
    STRINGSTRING