Nodes/Allergic Pack/Master Batcher (Allergic)
ComfyUI Node

Master Batcher (Allergic)

Sweep every folder in the pile, one queue run at a time

By usrname0·Created about a year ago·Updated 5 months ago· 2
Master Batcher (Allergic)
    • images
    • masks
    • images_loaded
    • folder_path
    • total_batches
    folder_paths
    batch_size1
    batch_index0
    reset_batch_to0
    sort_methodalphabetical
    load_alwaystrue

    Core ComfyUI's Load Image Batch is fine until the day you need to process images from several folders in one run. Then you're either swapping folder paths by hand, or stacking multiple loaders with a switch, and both are chores. Master Batcher is the Allergic Pack's answer: a batched image loader that takes a list of folder paths, auto-increments through all of them batch by batch, and hands you the right images and the right folder path every single run.

    It's the flagship of the pack - the node the author (usrname0, aka AllergicToTeeth on r/comfyui) wrote first for his own batch jobs. If you've got a pile of folders and a queue you'd rather not babysit, this is the node you're after.

    How it works

    On each run the node rebuilds a global "batch map" from your input, then reads one batch out of it based on the current batch_index:

    • Every line in folder_paths is sanitized (same shared path-cleaner as the pack's other nodes) and must be a real, existing directory.
    • Files are filtered to image extensions - png, jpg, jpeg, bmp, tiff, tif, webp - and sorted by the method you pick.
    • Files are chunked into groups of batch_size. Each chunk is one batch, and batches are ordered folder by folder: all of folder 1's batches first, then folder 2's, and so on.
    • batch_index auto-increments after each run (the control_after_generate trick again) and maps to one position in that global list. When you run past the end, you get an empty tensor and a DONE status so downstream nodes can stop.

    Images get exif_transpose applied (no more sideways phone photos), any alpha channel is extracted into a masks output (ComfyUI convention: transparent = 1, opaque = 0), and if a batch mixes image sizes, everything is resized to match the first image with LANCZOS - so mixed-size folders work, at the cost of some squishing.

    The load_always toggle is worth understanding: when on (it's the default), the node's IS_CHANGED returns NaN, which defeats ComfyUI's caching and forces a reload every run - so new files you drop into the folder get picked up without touching anything. The catch is that this cache-bust makes every run (and everything behind it) rerun, so flip it off once your folder is static and you want the speed back.

    The inputs that matter

    Only a handful, honestly:

    • folder_paths - one folder path per line. This is the whole point of the node.
    • batch_size - images per batch, 1 to 1000.
    • sort_method - seven options: alphabetical (and reverse), newest/oldest by modified date, newest/oldest by creation date, or random.
    • batch_index - auto-increments; leave it alone unless you're restarting mid-run.
    • reset_batch_to - what the Reset Batch button snaps batch_index to.
    • load_always - the reload-forever toggle above.

    Outputs

    Five of them: images (IMAGE) and masks (MASK) feed your pipeline; images_loaded (INT) tells you how many made it into the current batch; folder_path (STRING) is the folder the current batch came from - wire it into a filename prefix so your saves land in the right place; and total_batches (INT) is the grand total, which you can use for progress math. A Calculate Batches button counts everything without loading a single image, and the output slots get live labels like images_loaded: 8 (batch 3/12) after each run.

    Installing it

    Master Batcher ships with the rest of the Allergic Pack. ComfyUI Manager → search "Allergic Pack" → install the latest release, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/usrname0/ComfyUI-AllergicPack.git
    cd ComfyUI-AllergicPack
    pip install .    # Windows portable: ..\..\..\python_embeded\python.exe -m pip install .
    

    Restart, and it's under "Allergic Pack". No model downloads, no extra dependencies - the pack's requirements file is empty.

    Where people get burned

    Three things, mostly. Invalid or empty folders are silently skipped (the message only goes to the console), so a typo'd path just makes your total smaller. Batch order is folder-major, not round-robin - know that before you assume the output alternates. And a batch of mixed-resolution images gets resized to the first one, so if you care about native resolution, sort your files so each batch is uniform. None of these are showstoppers; they're just the shape of the tool.

    CategoryAllergic Pack

    Inputs (6)

    NameTypeDefaultDescription
    folder_pathsSTRINGOne folder path per line
    batch_sizeINT11–1000Number of images per batch
    batch_indexINT0Current batch index (auto-increments)
    reset_batch_toINT0Value to reset batch_index to when Reset is clicked
    sort_methodCOMBOalphabeticalHow to sort files within each folder
    load_alwaysBOOLEANtrueWhen True, bypasses caching to always reload images

    Outputs (5)

    NameTypeDescription
    imagesIMAGE
    masksMASK
    images_loadedINT
    folder_pathSTRING
    total_batchesINT