Nodes/ComfyUI-FolderBatch/FolderBatch Text Queue
ComfyUI Node

FolderBatch Text Queue

One prompt per run, auto-advanced

By aiai-r·Created 8 months ago·Updated about a month ago· 3
FolderBatch Text Queue
    • text_path
    • file_name
    • text_count
    • line_index
    source_modefolder
    unit_modefile
    folder
    text_path
    extension*.txt
    start_at0
    auto_queuetrue
    sort_byName
    order_byA-Z
    skip_empty_linestrue
    text_count0
    progress0.000
    repeat_count1
    repeat_index0

    The most common ComfyUI batch job has nothing to do with pixels: it's "generate an image for each of these 80 prompts." The standard workflow is one CLIP Text Encode, one prompt, one image, and a human doing the swapping. FolderBatch Text Queue is the iterator that turns a plain text file into a prompt pipeline - every execution it emits one text item, then advances to the next, optionally auto-queueing each run.

    Unlike the other queues in this pack, it has two modes that compose. source_mode picks where text comes from: folder scans a directory for *.txt files, while file points at one single text file. unit_mode picks what counts as "one item": file means each text file is one item, line means each non-blank line of the file is one item. So you can queue a whole folder of prompt files, or one big prompt file line-by-line - the line mode is the one most people actually want for batch generation, because a 50-line prompts.txt is a lot easier to maintain than 50 files.

    One rule the author enforces in code: source_mode=file only works with unit_mode=line. Pick file+file and the node raises a ValueError rather than guessing. Set start_at to resume mid-list, sort_by (Name/Date/Random) + order_by for traversal, and skip_empty_lines on for line mode so blank lines don't burn an execution.

    The Text Queue also has a trick the other queues don't: repeat_count. It's an optional input that makes the queue hold each text item for N executions before advancing - set it to 3 and every prompt in your list generates three images before the queue moves on. The repeat_index optional input tracks where within the current item you are. Pair this with a seed that increments each run and you've got "N variations per prompt" with zero babysitting.

    Outputs: text_path (current file path), file_name (base name, no extension), text_count (total items), and line_index - the original 0-based line number in line mode, or -1 in file mode. The canonical hookup is text_path and line_index into FolderBatch Load Text, then its text output into your positive-prompt conditioning.

    Install is the pack's shared story: Manager, search "ComfyUI-FolderBatch", restart, no models, no extra deps. The one setup trap is matching skip_empty_lines on both sides - if the queue skips blanks but the loader doesn't, the line numbers drift and you'll get prompts landing on the wrong lines. Keep the flag identical on both nodes and the loop is genuinely set-and-forget.

    CategoryFolderBatch/Text

    Inputs (14)

    NameTypeDefaultDescription
    source_modeCOMBOfolder2 options: folder, file
    unit_modeCOMBOfile2 options: file, line
    folderSTRING
    text_pathSTRING
    extensionSTRING*.txt
    start_atINT0
    auto_queueBOOLEANtrue
    sort_byCOMBOName3 options: Name, Date, Random
    order_byCOMBOA-Z2 options: A-Z, Z-A
    skip_empty_linesBOOLEANtrue
    text_countoptINT0
    progressoptFLOAT0.0000–1
    repeat_countoptINT1
    repeat_indexoptINT0

    Outputs (4)

    NameTypeDescription
    text_pathSTRING
    file_nameSTRING
    text_countINT
    line_indexINT