PD:Text Save Path
Save text to numbered files without fighting ComfyUI's cache
- success
- saved_count
The text writer with a real filename scheme
PDTEXT_SAVE_PATH ("PD:Text Save Path") writes text to disk with an actual file-naming system: output folder, base filename, delimiter, zero-padding, and a toggle for whether the number goes first or last. You hand it text, it produces text_001.txt (or 001_text.txt, your choice) in ComfyUI/output/text_output/, auto-incrementing so reruns never overwrite. It also tells you whether it worked and how many files it saved.
Every generation workflow eventually needs to save its prompt, seed, or captions to a file, and ComfyUI core has no dedicated text-save node worth the name. This one slots right where you'd expect - the output conventions are the standard ones the KB's image-io-metadata.md documents: saves land under output/, and you read them back from there. If you're batch-captioning, this is the tail end of the pipeline the pack's text-list nodes feed.
How it works
The source resolves the output directory from ComfyUI's folder_paths.get_output_directory(), so files always land under output/ plus your output_folder (default text_output), created on the fly. The input text is split into a list three ways: if it parses as JSON and is a list, each element becomes a file; if it's multiline, each non-empty line becomes a file; otherwise it's a single file. Then it names each file per your scheme - filename_delimiter_counter.ext with padding digits, or counter-first when number_start is on - and walks the counter past anything that already exists.
The clever bit is refresh_each_run. ComfyUI caches aggressively, and a text-save node whose inputs didn't change would otherwise be skipped. The node overrides its change detection to re-run every time when that toggle is on (it's the always-rerun trick from comfyui-node-plumbing.md). If your text never saves and you're sure the path is right, this toggle is the first thing to check.
Inputs and outputs
text(required) - the content to save. Wired in from another node.output_folder,filename,delimiter,padding,number_start,file_extension(txt/json/csv/log/md),refresh_each_run.- Outputs:
success(boolean - saved at least one file) andsaved_count(int).
Installing it
Part of Comfyui_PDuse:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse.git
cd Comfyui_PDuse
pip install -r requirements.txt
Or search "Comfyui_PDuse" in ComfyUI Manager and restart.
The gotchas worth knowing
Files land under ComfyUI/output/, not wherever you might have typed - output_folder is a subfolder name, not an absolute path, so don't expect it to write to /home/you/captions. Empty lines are skipped, which is usually what you want but can make a numbered batch come out with gaps. And the split-on-multiline behavior means a deliberately multiline single caption gets broken into several files - if your text legitimately contains newlines, feed it as a JSON-encoded string instead. Minor stuff, all of it; for a reliable numbered text sink this is one of the better ones.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| output_folder | STRING | text_output | — |
| filename | STRING | text | — |
| delimiter | STRING | _ | — |
| padding | INT | 10–9 | — |
| number_start | BOOLEAN | false | — |
| file_extension | COMBO | txt | 5 options: txt, json, csv, log, md |
| refresh_each_run | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| success | BOOLEAN | — |
| saved_count | INT | — |