SaveTextToFileByImagePath
Write a caption file next to its image, automatically named
- text_path
The captioning-pipeline node: give it an image's path and some text, and it writes that text into a .txt file using the image's own filename - same name, .txt extension, sitting right next to it. That's exactly the naming convention most LoRA and fine-tuning dataset tools expect (image.png next to image.txt), so this is the node you reach for at the end of an auto-captioning workflow rather than hand-naming files yourself.
The inputs and outputs that matter
image_path(STRING) - the image's path; the.txtfilename gets derived from this, but the image itself doesn't have to already exist for the node to work.text(STRING, multiline) - the caption or content to write.text_path(STRING) - the output, handing back the path it just wrote to, so you can chain it into a log, an upload step, or a sanity check.
How to install it
Via ComfyUI Manager: search comfyui-easyapi-nodes, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt
Restart ComfyUI. No models needed.
Common issues & troubleshooting
There's a pack-wide setting worth knowing before relying on this in a batch job. allow_create_dir_when_save, added in v1.1.3, controls whether saving text (and images) creates a missing target directory for you or fails instead. If a save that looks like it should work is erroring out, that config is usually the first thing to check rather than assuming the path string itself is malformed.
Feeding it a path to an image that doesn't exist yet still works. This node doesn't verify the image is real - it only derives a filename from the path string and writes the text file. That's convenient for pre-writing captions ahead of a generation step, but it also means a typo in image_path silently produces a caption file sitting next to nothing, rather than an error telling you the image is missing.
Pairs naturally with LoadLocalFilePath if you're captioning a whole folder - loop the image paths it returns through this node alongside whatever caption text your workflow generates.
It overwrites silently, same as its SaveTextToLocalFile sibling. Run a captioning pass twice over the same folder and the second pass replaces the first .txt file for each image without warning - there's no append and no confirmation. That's usually exactly what you want for re-captioning, but it's worth knowing before you run an experimental caption model over a folder you already hand-corrected.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image_path | STRING | — | |
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text_path | STRING | — |