Nodes/ComfyUI DashuaiTools/LoadTextList☀
ComfyUI Node

LoadTextList☀

Reading 500 prompts from a folder, without 500 text nodes

By Hasasasa·Created about a year ago·Updated 2 months ago· 7
LoadTextList☀
    • texts
    • file_name
    folder_path
    max_output0
    start_index0
    sort_mode
    always_reloadfalse

    Every batch workflow has the same bottleneck: you've got a folder of prompts, captions, or prompt variants, and ComfyUI wants them one node at a time. LoadTextList reads a whole folder of .txt files into two list outputs, in a controlled order, with sensible decoding fallbacks. It's the text twin of the pack's LoadImageList and it slots into any batch-prompt or dataset pipeline.

    How it works

    It globs every *.txt in folder_path, sorts them however you ask, slices out a window with start_index and max_output, then reads each file with an encoding cascade: UTF-8 first, then the common Chinese encodings GBK, GB2312, and BIG5, and finally - if all of those fail - a raw-bytes repr string so a weird file doesn't kill the whole run. That last bit is the author being practical: mixed-encoding caption datasets are a real thing, and a node that crashes on one bad file is worse than one that hands you something ugly but readable.

    The two outputs are both lists: texts (the file contents) and file_name (just the basenames, no path). Both are typed as list STRING, so wire them into nodes that accept lists - or run them through a list-to-single converter if your sampler wants one prompt at a time.

    The inputs that matter

    • folder_path - required; point it at the directory holding the .txt files.
    • sort_mode - None, or Alphabetical / Numerical / Datetime, each ASC or DESC. This is the input that makes results reproducible instead of filesystem-order roulette.
    • start_index and max_output - slice the list. max_output = 0 means "everything from start_index on".
    • always_reload - accepted, and honestly a bit vestigial: this version of the node never caches, so it always re-reads the folder fresh anyway. Toggling it changes nothing today.

    Gotchas

    • Numerical sort digs digits out of the filename. 01 and 1 both sort fine; a file with no digits at all sorts as zero, so mixed naming schemes can surprise you.
    • Files that hit the repr fallback aren't readable text. They're b'...' byte dumps. That's better than a crash, but check your log for which files decoded via fallback.
    • Only .txt. This node doesn't care about subfolders or other extensions.

    Install

    Part of the DashuaiTools pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Hasasasa/ComfyUI_DashuaiTools
    

    then restart ComfyUI, or install via ComfyUI Manager ("DashuaiTools"). No dependencies beyond Python's stdlib - this node is pure os/glob - so nothing to break.

    If you're doing prompt sweeps, caption reading, or any "one prompt per file, in order" job, this is the node that turns a folder into a pipeline.

    CategoryTools

    Inputs (5)

    NameTypeDefaultDescription
    folder_pathSTRING
    max_outputINT00–1000
    start_indexINT00–100000
    sort_modeCOMBO7 options: None, Alphabetical (ASC), Alphabetical (DESC), Numerical (ASC), Numerical (DESC), Datetime (ASC), +1
    always_reloadBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    textsSTRING
    file_nameSTRING