Nodes/WAS Node Suite v3/Load Text Batch
ComfyUI Node Runs on cloud

Load Text Batch

Read a folder of text files, such as a training set's captions, as one LIST and as a STRING list that runs the graph below once per file, each with its name. Wired filenames read the caption beside each image instead, in the images' order, ready to edit and save back by name.

By WASasquatch·Created 4 years ago·Updated 3 days ago· 1,900
Load Text Batch
  • filenames
  • texts
  • names
  • text
  • name
  • count
  • missing
  • folder
◄folder▾►
◄pattern*.txt►
◄extension.txt►
CategoryWAS Suite/IO

Inputs (4)

NameTypeDefaultDescription
folderCOMBOWhich folder to read. A bare 'input', 'output' or 'temp' is that folder itself; 'training/cats [input]' is that folder below it. Folders under paths.allow_read in config.yaml are listed under their own names. A wired path, such as `E:\images`, works too.
patternSTRING*.txtWhich files to read when filenames is not wired: `*.txt` = every .txt in the folder; `**/*.txt` = in its subfolders too; `cat_*.txt` = only those named that way. Ignored while filenames is wired.
extensionSTRING.txtEnding added to each wired name: `.txt` reads cat.txt for `cat`; `.caption` reads cat.caption. An image ending on the name, as `cat.png`, is dropped first. Ignored while filenames is not wired.
filenamesoptARRAY,STRINGOne name per text to read, as filename_list from Load Image Batch: `cat` reads cat.txt, `set_b/cat` reads set_b/cat.txt. A name with no readable file gives an empty text in its place, so entry 3 always belongs to name 3. Several lines are several names.

Outputs (7)

NameTypeDescription
textsARRAYEvery text on one wire, in order, for Text List Get, Text List Slice and Text List Length. Entry 3 here is the text of name 3 in names.
namesARRAYThe name each text came from, on one wire and in the same order: the path below the folder without its ending, as `cat` or `set_b/cat`, the form Image Save and Save Text File take as filenames.
textSTRINGThe same texts as a STRING list, so the graph below runs once per file: wire it into a text edit, then into Save Text File's text.
nameSTRINGThe name that goes with each run of text. Wire it into Save Text File's filenames to write each edited text back under its own name.
countINTHow many entries both lists hold: files read, or names wired.
missingINT0 = every wired name had a readable file; 3 = three names got an empty text. Always 0 while filenames is not wired. The log names each file that was unreadable or not UTF-8.
folderSTRINGThe picked folder below its root with a trailing slash: `training/tus [input]` = `training/tus/`; a root itself = empty. Wire it into Save Text File's filename_prefix to write back into the same folder.