Nodes/ComfyUI-ZML-Image/ZML_写入文本
ComfyUI Node

ZML_写入文本

Save a prompt to a .txt from inside the graph — ZML_写入文本

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_写入文本
    • Help
    文本A
    文本B
    保存路径

    ZML_写入文本 is the opposite of the pack's text-loading nodes: instead of reading a prompt in, it writes one out - to a plain .txt file on disk, right from the middle of a workflow. It's an output node, the kind you hang at the end of a chain to archive whatever text that run produced.

    The interface is almost aggressively simple. Three required inputs: 文本A, 文本B, and 保存路径. Run time concatenates A and B (stripping the join so you don't get a gap), then decides where to write:

    • 保存路径 empty → writes to the pack's own zml_w/txt/Text input/文本输入.txt (the author's default scratch file)
    • path is a folder → writes to 文本输入.txt inside it, creating the file if needed
    • path ends in .txt → writes exactly there (the only format supported)

    The single output is Help, a STRING with usage notes - useful if you feed it into a note/display node, otherwise ignore it. Because it's OUTPUT_NODE = True and marks IS_CHANGED as NaN, it always executes and always writes, which is what you want from a logging node: no cache skipping.

    Why bother when you could just copy the prompt? Because it runs inside the graph. Feed it the output of a ZML_文本列表 loop and every iteration archives its prompt to disk, giving you a batch log for free. Feed it a formatter's output and you've exported a cleaned prompt library. For people who live by the pack's text-block ecosystem - the README says the whole pack started as a way to save prompts with images - this is the piece that gets those prompts out of ComfyUI and into a folder you can grep.

    Installing it

    Ships in ComfyUI-ZML-Image. ComfyUI Manager → ComfyUI-ZML-Image, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zml-w/ComfyUI-ZML-Image
    

    Restart. No models, no downloads - this is pure Python file I/O. Chinese UI; English patch at https://github.com/zml-w/ZZZ_ZML_English_Patch.

    Common issues

    Path handling is where people get burned. If you pass a path that doesn't exist and isn't obviously a file or folder, behavior depends on the endswith('.txt') test - a typo like my_prompts.tx falls through to folder logic and silently writes to 文本输入.txt inside a directory that may not exist. Create the folder first, or always use a full .txt path. Also note: only .txt is accepted; there's no append mode documented, so every run overwrites the target file. If you want an archive of many runs, point each run at a distinct filename (the pack's filename/numbering nodes work well for that).

    One thing that surprises people: it's an output node, so it appears at the end of the execution order and runs even if you forgot to connect it to anything upstream - it just writes whatever A and B hold. That's a feature for logging, but it means a leftover WriteText in a workflow you share will keep writing to disk on every run. Check for strays before you send a workflow to a friend.

    Fair warning, same as every node in this pack: solo dev, Chinese-first, updated frequently. The path logic here is simple enough to be trustworthy, but if your run "doesn't save," check the Help output first - it spells out the three path behaviors.

    Categoryimage/ZML_图像/文本

    Inputs (3)

    NameTypeDefaultDescription
    文本ASTRING
    文本BSTRING
    保存路径STRING

    Outputs (1)

    NameTypeDescription
    HelpSTRING