Nodes/ComfyUI_PromptBatcher/Save Text To Files
ComfyUI Node

Save Text To Files

Paste a stack of prompts, get files — the write side of a prompt batch

By juemingai·Created about a year ago·Updated about a year ago· 19
Save Text To Files
    • output_path
    • file_prefix
    text
    output_directoryinput
    file_prefixScene

    Save Text To Files is the boring half of the ComfyUI_PromptBatcher pair, and boring is fine - it does one job cleanly. You paste a bunch of prompts into a multiline text box, one per line, and it writes each non-empty line out to its own .txt file. That's it. No models, no API, no weights to download. It's meant to be the "prepare your prompts" step before Load Prompts From Dir feeds them into a batch generation loop.

    Why would you bother? Because if you're running long prompt batches in ComfyUI - same scene across styles, a character sheet where each line is a different camera angle - the queue is easier to manage from files than from fiddly per-node text widgets. You can edit the list in any text editor, re-run a batch, and keep a permanent record of what you actually generated with. This node is how the prompt text gets from your head into that file system. Pair it with the loader from the same pack and you've got a "generate from a folder of prompts" pipeline with zero extra dependencies.

    How it works

    The mechanism is pure Python stdlib, which is exactly why it's safe to install and never drags your environment into dependency hell. Under the hood:

    • It splits text on newlines and skips blank lines.
    • Each line becomes {file_prefix}_{NNNNN}.txt, zero-padded to five digits - so with the default prefix you get Scene_00001.txt, Scene_00002.txt, and so on.
    • It never overwrites. If Scene_00001.txt already exists, it bumps the counter until it finds a free name. Re-run the same batch and you get new files appended, not clobbered.

    The two inputs that matter:

    • text - required, a multiline box. One prompt per line, every line is a file.
    • file_prefix - defaults to Scene. The name prefix for the generated files.
    • output_directory - defaults to input.

    That last one is the trap. If you give a relative path, it's resolved against ComfyUI's working directory (usually the ComfyUI root), so input means ComfyUI/input. If you give an absolute path, it's used as-is and the folder is created if it doesn't exist. So the default writes into your ComfyUI input folder, which is convenient for feeding the loader next - but if you expected it relative to your workflow file, you'll wonder where your files went. Use an absolute path when you want them somewhere you can actually find.

    Outputs

    It returns two STRING outputs: output_path (the absolute path of the directory the files landed in) and file_prefix (the prefix used). Handy for display or for wiring into other text nodes - neither is essential.

    Install

    ComfyUI Manager: search "ComfyUI_PromptBatcher" and install. Or, the manual route:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/synthetai/ComfyUI_PromptBatcher
    

    Restart ComfyUI. That's the whole install - the pack's requirements.txt literally says "no external dependencies required," and it means it. No model downloads, no pip fights. It's also MIT licensed.

    Gotchas

    • Relative output_directory paths depend on where you launched ComfyUI from. Absolute paths don't. When in doubt, go absolute.
    • There's no "clear" - re-running appends new numbered files rather than starting over. If you want a clean batch, empty the folder first.
    • Files are written UTF-8 and each line is stripped of leading/trailing whitespace, so multi-word prompts survive intact, but don't expect multi-line formatting inside a single file.

    Honestly, if you never use this node, the loader from the same pack is still worth having. But once you're maintaining a library of prompt batches on disk, you'll want a quick way to author them from inside ComfyUI - and this is exactly that, with nothing clever to break.

    CategoryPromptBatcher

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    output_directoryoptSTRINGinput
    file_prefixoptSTRINGScene

    Outputs (2)

    NameTypeDescription
    output_pathSTRING
    file_prefixSTRING