Nodes/ComfyUI-OllamaPromptsGeneratorTlant/Load Sequenced Txt File Tlant
ComfyUI Node

Load Sequenced Txt File Tlant

Step Through Prompts in Order

By Tlant·Created 2 years ago·Updated 5 months ago· 2
Load Sequenced Txt File Tlant
    • text
    • txt_file_path
    • txt_filename
    dir_path
    txt_index0
    is_recursivefalse

    The name says "Sequenced" and that's exactly the point: this node is the ordered sibling of the random loaders in the Tlant pack. Instead of rolling the dice, it sorts every .txt file in a folder by filename and serves them one at a time as you bump an index. If you're batching out variations and want prompts 01, 02, 03 to fire in a known order - or you're pairing each prompt file with a specific image and need the pairing to hold - this beats the random versions.

    How it works

    It scans dir_path (recursively if is_recursive is "true"), collects every .txt, sorts the full paths ascending, and then uses your txt_index to pick one with modulo math: selected_index = txt_index % len(txt_files). That's the clever bit - the index wraps around, so you can drive the counter from anything (an animation frame, a for-loop, a slider) and never run off the end of the list. Index 0 gets the alphabetically-first file, and once you pass the last one it loops back to the start.

    Reading uses the usual utf-8gbklatin-1 fallback chain, and it's one of the friendlier members of the family: three outputs, including both the full path and the bare filename.

    Inputs and outputs

    • dir_path - absolute folder path.
    • txt_index - the counter. Default 0, min 0, effectively unbounded because of the modulo wrap.
    • is_recursive - "true"/"false" enum, default "false".

    Outputs: text (file contents), txt_file_path (full path of the selected file), and txt_filename (just the filename, no directory - handy for logging or naming outputs after the prompt that made them).

    Install

    One pack install covers all sixteen nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Tlant/ComfyUI-OllamaPromptsGeneratorTlant
    

    restart, done. Or find "Load Sequenced Txt File Tlant" in ComfyUI Manager.

    Where people get tripped up

    • Order depends on filename, not creation time. "Sequenced" here means alphabetical sort. If your files are prompt1.txt, prompt10.txt, prompt2.txt you'll get 1, 10, 2 - zero-pad your filenames (prompt01.txt) if you care about numeric order.
    • Same error-as-output trap as the rest of the family. Bad directory or no .txt files → the error message lands in text, not in the console.
    • One caveat on "loops": the modulo wrap is per-execution, not a remembered position. Drive txt_index from something external that counts up; the node itself doesn't track where you are.

    It's the load-order control the random loaders deliberately don't give you. When you need deterministic order instead of a dice roll, this is the one.

    CategoryTlant/File Operations

    Inputs (3)

    NameTypeDefaultDescription
    dir_pathSTRING
    txt_indexINT00–18446744073709550000
    is_recursiveCOMBOfalse2 options: true, false

    Outputs (3)

    NameTypeDescription
    textSTRING
    txt_file_pathSTRING
    txt_filenameSTRING