DataSet_TextFilesLoad
Load Every Caption in a Folder, All at Once
- TextFileNames
- TextFileNamesWithoutExtension
- TextFilePaths
- TextFileContents
The front door of this pack's caption pipeline. DataSet_TextFilesLoad points at a directory and pulls every .txt file out of it - names, names without extensions, full paths, and contents - as four parallel lists. From there you can edit the captions, analyze them, or feed them to a chat node, then write them back with DataSet_TextFilesSave.
If you've got a training folder full of captions and you want to do anything with them as a batch inside ComfyUI, this is the node that gets them in. It's the load side of the pack's core loop, and it pairs with basically everything else in the suite.
Inputs and outputs
The single input, directory, is a plain string path to the folder. Widget works fine here - the node handles a single value by treating it as a one-item list internally, so you don't need to overthink it. Only files ending in .txt are picked up; everything else is ignored.
Four list outputs, all aligned by index:
- TextFileNames -
photo_001.txt. - TextFileNamesWithoutExtension -
photo_001. This is the one you feed to save nodes when you want captions and images to share base names. - TextFilePaths - the full paths.
- TextFileContents - the actual caption text, one per file.
How it works
It lists the directory, filters for .txt, and reads each file with plain Python. Nothing clever, which is the right call for a loader - no encoding guesses beyond the default, no recursion into subfolders (a single level only), no hidden-file special cases. The file-reading order comes from the directory listing, so the lists stay aligned with each other even if the sort order isn't what you expected.
Installing
It ships in the ComfyUI-DataSet pack:
cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-DataSet.git
cd ComfyUI-DataSet && pip install -r requirements.txt
Restart ComfyUI and it appears under 🔶DATASET🔶. No models, no extra downloads.
Common issues and honest limits
A few things to keep in your back pocket. First, it's not recursive - captions nested in subfolders won't be found; point the node at each subfolder or reorganize. Second, it's .txt only by design - if your dataset uses .txt alongside something else, only the txt files come through. Third, the output is "output node"-flagged, which means ComfyUI marks the graph as complete when this node runs - fine for a data pipeline, but know that it counts as a terminal step.
Also worth noting: there's a sibling node, DataSet_TextFilesLoadFromList, that does the same job from a list of explicit file paths instead of a whole directory. Use this one when you want the whole folder; use that one when you've already filtered down to specific files. For a quick "show me my captions" pass, this is the one to grab.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | directory_path | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| TextFileNames | STRING | — |
| TextFileNamesWithoutExtension | STRING | — |
| TextFilePaths | STRING | — |
| TextFileContents | STRING | — |