ComfyUI Node

Exec

Dump a whole folder of prompt files into one text string

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
Exec
    • STRING
    path
    pattern*.txt

    Say you keep your prompts as .txt files - one per concept, maybe a folder of them for a project. Dragging each one into a node by hand is misery. Exec (which maps to the io - get file list and read as text implementation) is the shortcut: point it at a directory with a glob pattern, and it reads every matching file and returns the concatenated contents as a single string. It's the bulk loader for text that most workflow UIs forgot to include.

    The display name is a lie, by the way - it doesn't execute anything, call an API, or run code. It's exec as in the internal FUNCTION = "exec" that the whole pack uses. Don't let the name scare you off; it's a dumb file reader with a glob.

    How it works

    Two small steps, both from the pack's node_pyio.py helpers. First it globs the directory with your pattern (default *.txt) to collect matching absolute paths. Then it opens each file, reads the text, and joins them all with newlines into one output string. The join matters: you get file1 contents + newline + file2 contents, not a mashed-together blob, so you can still tell where one file ends and the next begins.

    Inputs and outputs

    • path - the folder to scan. Absolute paths are your friend here; a bare relative path resolves against wherever ComfyUI was launched.
    • pattern - the glob, default *.txt. Use *.md, *.safetensors.txt, [ab]*.txt, whatever Python's glob supports.
    • Output: one STRING with all matched file contents, newline-joined.

    From there, feed it into ymc's show text to eyeball it, or pipe it into your prompt pipeline if you've structured your files as prompt fragments.

    Installing it

    # ComfyUI Manager: search "ymc suite" and install ymc-node-suite-comfyui
    # or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui
    

    Restart after installing. Dependencies are four small pure-Python PyPI helpers that self-install on load. No models, no GPU footprint - it's plain filesystem I/O.

    Gotchas

    • No recursion. The glob is os.path.join(dir, pattern) against one directory; it won't walk subfolders. If your files are nested, use a pattern like **/*.txt... which glob supports in newer Python only - if that silently returns nothing, flatten the folder.
    • If the directory doesn't exist or nothing matches, you get an empty string, not an error. Silent empty output is the most common "why is my prompt blank" trap.
    • Non-UTF-8 files will throw on read; keep your prompt files plain UTF-8.
    • If you also run WAS Node Suite, Manager may flag shared node names between the packs - disable one if you see save-node conflicts.
    Categoryymc suite/text/io

    Inputs (2)

    NameTypeDefaultDescription
    pathSTRING
    patternSTRING*.txt

    Outputs (1)

    NameTypeDescription
    STRINGSTRING