πΎ Save Text File With Path
Write Text to Disk and Get the Path Back
- output_full_path
- output_name
- output_path
ComfyUI is good at saving images and bad at saving anything else. Prompts, captions, JSON blobs, a log of what a batch did - there's no built-in node for "put this text on disk". πΎ Save Text File With Path does it, and the second half of its name is the part that matters: it hands back the file's path, so a downstream node can find what it just wrote.
The reason to reach for this specifically (it's adapted from YMC's Save Text File, with the path outputs added) is that path. Caption a dataset and you want the caption file next to the image; export a prompt and you want the same name applied to the PNG; log a run and you want the log to reference the output. Path in, path out.
How it works
file_text is what gets written, and the rest of the inputs build the filename from four parts: {prefix}{counter_separator}{counter}{counter_separator}{suffix}{extension}. path is the folder underneath ComfyUI/output/ - you cannot write outside it, and the node actively refuses .. traversal with an error. Missing folders are created rather than skipped.
Both path and prefix support a [time(...)] token that takes Python strftime directives, and the defaults use it: the path default is [time(%Y-%m-%d)]/, so files land in a dated subfolder, and the prefix default is a full date-and-time stamp. If you want every run in one flat folder, blank the time token out and set your own prefix.
The counter is looked up rather than assumed: the node scans what's already in the destination folder and picks the next free number, which is why repeated runs don't overwrite each other. counter_length (default 3 β _001) pads it, and counter_separator (default _) is what sits around it. Set counter_length to 0 if you don't want a counter at all.
It also sanitises the prefix and suffix, truncates them to stay clear of Windows' path-length limits, and raises if output_extension is blank. It's a small node that's clearly been used hard.
Inputs and outputs
Required inputs are file_text, path, prefix, counter_separator, counter_length, suffix, output_extension - not all of them need editing, but note only delimiter-style defaults are provided for most. Realistically you set file_text, path and output_extension, and leave the naming defaults alone until you have a reason.
Outputs: output_full_path (absolute path to the file), output_name (filename only), and output_path (the formatted folder). output_full_path is the one to wire into anything downstream that reads files, or into a note so you can find it. It's flagged as an output node, so it runs even with nothing connected after it.
Install
ComfyUI Manager β search "ComfyUI-mnemic-nodes" β install β restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
No downloads. The pack's requirements.txt installs its wider dependency list for other nodes - this one is standard library plus what ComfyUI already ships.
Common issues
Files aren't where you expected. They're under ComfyUI/output/, and the default path puts them in a dated subfolder. Also check the [time()] token didn't hand you a folder you forgot about.
"Path contains invalid characters" / outside the output directory. Working as intended - .. and absolute escapes are blocked. The output directory is the sandbox.
The extension is empty. It raises. Put something back in output_extension.
Overwritten files. Only if you zeroed counter_length or fixed the prefix to a constant. The auto-counter exists for a reason.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| file_text | STRING | The text to save. | |
| path | STRING | [time(%Y-%m-%d)]/ | The folder path to save the file to. The following creates a date folder: [time(%Y-%m-%d)] |
| prefix | STRING | [time(%Y-%m-%d - %H.%M.%S)] | The prefix to add to the file name. The following creates a file with a date and timestamp: [time(%Y-%m-%d - %H.%M.%S)] |
| counter_separator | STRING | _ | The separator to use between the file name and the counter. |
| counter_length | INT | 30β24 | The number of digits to use in the counter. |
| suffix | STRING | The suffix to add to the file name after the counter. | |
| output_extension | STRING | txt | The extension to use for the output file. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| output_full_path | STRING | The full path to the saved file |
| output_name | STRING | The name of the saved file |
| output_path | STRING | The formatted path to the saved file (excluding filename) |