Nodes/ComfyUI_PromptBatcher/Load Prompts From Dir
ComfyUI Node

Load Prompts From Dir

Point it at a folder of prompts and let the queue do the work

By juemingai·Created about a year ago·Updated about a year ago· 19
Load Prompts From Dir
    • PROMPT
    • FILE_PATH
    directory
    file_prefix
    file_load_cap0
    start_index0
    load_alwaysfalse

    Load Prompts From Dir is the reason the ComfyUI_PromptBatcher pack exists. It points at a folder full of .txt files, reads each one as a prompt, and hands ComfyUI a list of prompt strings plus the file paths. Wire that list into your sampler or conditioning and you've turned "generate 50 images one at a time, copying prompts around by hand" into "queue the whole batch and walk away." For anyone doing prompt-variety runs - wildcards, character sheets, style explorations - this is the boring-but-effective version of that workflow.

    The nice thing about the ComfyUI way of thinking here: this node outputs lists (both outputs are list-typed), so ComfyUI's batch machinery does the looping for you. One execution reads the folder, and the downstream sampler runs once per prompt in the list. You get reproducibility, too - the batch lives on disk as plain text files, which is a lot easier to version and reuse than a pile of node text widgets.

    How it works

    The loader is pure Python stdlib - no dependencies, no models, nothing to download. Here's what it actually does:

    • Lists the folder, keeps only .txt files (case-insensitive), and filters to names starting with file_prefix if you set one (also case-insensitive).
    • Sorts files by the first number found in the filename, not alphabetically - so prompt2.txt, prompt10.txt, prompt100.txt land in the order you'd expect, not 10, 100, 2.
    • Applies start_index (skip the first N files) and then file_load_cap (stop after N files; 0 means no limit).
    • Reads each file, strips surrounding whitespace, and returns the list of prompts plus the absolute paths.

    The three inputs you'll actually touch:

    • directory - required. The path to your prompt folder.
    • file_load_cap - default 0 (no limit). Set it to, say, 10 to do a dry run before committing to the full 300-file batch.
    • load_always - default off. When enabled, it forces a fresh read of the folder on every execution, which matters if the files change between runs. Leave it off for normal use - it re-reads only when something else changes, which is faster.

    That's the whole input list. start_index and file_prefix exist for splitting one folder into ranges, which is a genuinely useful trick when a batch dies partway through and you want to resume from file 40 without rebuilding anything.

    Outputs

    • PROMPT - the list of prompt strings. This is the one that matters; wire it into your CLIP text encode / KSampler path.
    • FILE_PATH - the list of absolute paths, useful if you want to echo "which file am I on" into a workflow or save results keyed to the source prompt.

    Install

    ComfyUI Manager: search "ComfyUI_PromptBatcher" and install. Or manually:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/synthetai/ComfyUI_PromptBatcher
    

    Restart ComfyUI. Zero extra dependencies, MIT licensed, nothing heavy. This is one of those packs where "no pip install needed" is the whole pitch.

    Gotchas

    • directory is used as-is - it's checked literally, not resolved against ComfyUI's input folder. That's a subtle inconsistency with the pack's sibling SaveTextToFiles, which does resolve relative paths under input. Give the loader an absolute path and save yourself the headache.
    • If the folder is missing, empty, or has no matching .txt files, the node throws a FileNotFoundError and the batch won't run - so a typo'd path fails loudly, not silently.
    • Individual files that fail to read are skipped with an error printed to the console, not a hard crash. You can end up with a shorter batch than you expected, so glance at the log if your count looks off.
    • Files without numbers fall back to string sorting, and only the first number in a name is used for the numeric sort - shot2_alt.txt and shot10.txt sort by 2 and 10, so name your files with the number up front.

    For a small pack by an unknown author, this is refreshingly predictable. It won't change your life, but if your prompt lists live in text files, it's the cleanest two-minute way to make them drive a whole queue.

    CategoryPromptBatcher

    Inputs (5)

    NameTypeDefaultDescription
    directorySTRING
    file_prefixoptSTRING
    file_load_capoptINT0
    start_indexoptINT0
    load_alwaysoptBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    PROMPTSTRING
    FILE_PATHSTRING