Nodes/ComfyUI-FolderBatch/FolderBatch Image Queue
ComfyUI Node

FolderBatch Image Queue

Feed a whole folder through, one file at a time

By aiai-r·Created 8 months ago·Updated about a month ago· 3
FolderBatch Image Queue
    • image_path
    • file_name
    • image_count
    folder
    extension*.png;*.jpg;*.jpeg;*.webp;*.bmp
    start_at0
    auto_queuetrue
    sort_byName
    order_byA-Z
    image_count0
    progress0.000

    There's a question that shows up in r/comfyui roughly every other week: "how do I process every image in a folder, one at a time, in order?" The old answer used to be core's LoadImageBatch node, which has since vanished, so the practical answer for most people became "change the filename, click run, repeat a hundred times." FolderBatch Image Queue is the "one item per execution" iterator that ends that grind: it scans a folder, hands you one image path per run, and can automatically queue the next one when the current run finishes.

    Here's the mental model. The node is a tiny stateful iterator, not a batch loader. On the first execution it globs the folder, sorts the results, and caches that list. Each run it hands back the file at start_at. Then the frontend does the clever bit - after the graph finishes, it bumps start_at by one and, if auto_queue is on, queues the next prompt for you. Land on the last file and start_at resets to zero, ready to start over. That's the whole loop: run, advance, re-queue, repeat.

    The inputs you actually set are few. folder is a plain path string, so paste the full absolute path (no directory-picker here). extension is a glob pattern - *.png by default, but you can give several at once separated by semicolons: *.png;*.jpg;*.jpeg;*.webp;*.bmp. start_at is your 0-based entry point, handy for resuming a run that died halfway. sort_by (Name / Date / Random) and order_by (A-Z / Z-A) decide traversal order - Date is the one you want for "newest first." The two optional inputs, image_count and progress, are UI display only; the node's own frontend code writes the running total and progress bar into them.

    Three outputs come out. image_path is the full path of the current file - wire it straight into FolderBatch Load Image and you're done. file_name is the base name without extension, which is gold for naming your saves so output filenames track input filenames. image_count is the total number of matching files.

    Installing is boring in a good way. In ComfyUI Manager search "ComfyUI-FolderBatch", install, restart - or clone it yourself:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aiai-r/ComfyUI-FolderBatch
    

    Then restart ComfyUI. The pack declares no extra Python dependencies and ships no model files - the image loader leans on Pillow and torch, which ComfyUI already has.

    Where people get burned: the file list is cached per node instance, keyed on folder + extension + sort order. Drop new images into the folder mid-run and it won't see them until that cache resets. auto_queue only works when the web UI is running - it literally calls app.queuePrompt() to fire the next run, so headless/API execution won't auto-advance unless you drive start_at yourself. And an empty folder doesn't error; it just returns an empty string and a count of zero, which will quietly feed an empty path into your loader.

    CategoryFolderBatch/Image

    Inputs (8)

    NameTypeDefaultDescription
    folderSTRING
    extensionSTRING*.png;*.jpg;*.jpeg;*.webp;*.bmp
    start_atINT0
    auto_queueBOOLEANtrue
    sort_byCOMBOName3 options: Name, Date, Random
    order_byCOMBOA-Z2 options: A-Z, Z-A
    image_countoptINT0
    progressoptFLOAT0.0000–1

    Outputs (3)

    NameTypeDescription
    image_pathSTRING
    file_nameSTRING
    image_countINT