CGA_TxtReaderNode
Dump a folder of .txt files into ComfyUI as parallel lists
- file_names
- file_contents
Sooner or later you'll want your prompts, captions, or translation source text to live in .txt files on disk instead of hardcoded into a workflow - so you can batch them, edit them without touching the graph, or run them through a translation pass. CGA_TxtReaderNode is the node that reads every text file in a folder and hands ComfyUI the lot of it, as two lists you can loop over.
It's a plain directory reader with no formatting, no preview, and no file picker. Point it at a folder, get lists back. The README explicitly suggests pairing it with a loop node for batch processing, and the pack's bundled Batch translation of txt workflow is exactly that: reader → loop → translate → save.
Inputs and outputs
- folder_path (STRING) - the folder to scan.
Outputs (both are Python lists, so wire them into nodes that accept LIST):
- file_names - the filenames with the
.txtextension stripped, soprompt_01.txtbecomesprompt_01. - file_contents - the full text of each file, read as UTF-8.
The two lists are parallel: file_names[i] corresponds to file_contents[i]. Keep them aligned - pull both with the same index (the pack's CGA_ExtractFromList is built for exactly this) or you'll match the wrong prompt to the wrong file.
The gotchas, from the source
Three things will trip you up if you're not expecting them.
- Invalid path raises. Unlike its sibling
CGA_ListSubfolders, which returns empty results for a bad path, this node throws aValueErrorif the folder isn't a valid directory. Your run stops. Double-check the path. - UTF-8 only. Files are read with
utf-8encoding. A file saved as UTF-16, Latin-1, or with a stray BOM will throw a decode error. For text you're feeding into CLIP encoders or LLM translation, UTF-8 is the norm - just know it's enforced. - Non-recursive and .txt only. Only the immediate files in the folder, only
.txtextensions. No subfolders, no other formats.
Install
Standard for this pack: ComfyUI Manager → search ComfyUI_CGAnimittaTools → install → restart, or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/cganimitta/ComfyUI_CGAnimittaTools
No models, no downloads, and the requirements.txt is just torch, numpy, pathlib - nothing that isn't already in your ComfyUI environment. Find it under CGAnimittaTools after restart.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| file_names | LIST | — |
| file_contents | LIST | — |