Nodes/ComfyUI LC123 Nodes/LC Image Batch From Folder 📂
ComfyUI Node

LC Image Batch From Folder 📂

Stop wiring 40 Load Image nodes

By lonecatone23·Created 3 months ago·Updated a day ago· 46
LC Image Batch From Folder 📂
    • images
    • count
    • total_found
    • filenames
    ◄folder_path►
    ◄start_index0►
    ◄max_images0►
    ◄size_modecrop►
    ◄include_subfoldersfalse►

    Here's a job ComfyUI makes weirdly annoying: you have 60 frames in a folder and you want them as one IMAGE batch, in order, to push through an upscale or a denoise. Core gives you Load Image, one file at a time. So people build the same ugly Rube Goldberg machine of thirty loaders into a batch node, or they rename files and hope. LC Image Batch From Folder 📂 loads the entire folder as a single batch instead, sorted the way a human would sort it - img2 before img10, not the lexicographic mess you get from a naive string sort.

    How it works

    Point it at a folder and it walks the files with one of eight accepted extensions - png, jpg, jpeg, webp, bmp, tif, tiff, gif (first frame only) - and sorts them with a natural-order key that splits names on digits. That's the whole reason img2.png lands before img10.png.

    The path handling is unusually forgiving, because it was clearly written by someone who got tired of support questions. A full path works. So does a folder name inside ComfyUI/input, which is where relative paths resolve. Paste it with quotes - straight or curly - with backslashes, with a trailing slash, with ~, with an environment variable, even with file:/// on the front, and it gets cleaned up. Paste the path to one image rather than the folder and it uses that image's folder. That last one is a small thing that saves a lot of trips to a file manager.

    Every image is EXIF-rotated and converted to RGB, and the first image you load sets the size - anything that doesn't match gets fitted by size_mode: crop to fill (the default), pad with black, or stretch. Then the whole set is stacked into one tensor.

    It also fingerprints the folder: the node's change-detection hashes every file's path and modification time, so dropping a new frame in and re-queuing picks it up without you touching a widget. That's the polite version of the always-rerun trick - it re-reads when the folder actually changed, not every single queue.

    The inputs that matter

    Two required settings do the real work, and one is a lifesaver:

    • folder_path - as forgiving as described above. Leave it empty and the node raises a clear error rather than silently returning nothing.
    • max_images - 0 means all of them. Set it to 8 and you process the folder in chunks. This is the knob that keeps a low-VRAM box from dying on a 500-image folder, and it's the one people forget exists before concluding the node "doesn't work on big folders".
    • start_index - skip N images first, so you can work through the folder in windows or resume after a crash. In practice: set start_index 40, max_images 8, and you're testing frames 40-47.

    include_subfolders walks the tree if your images are nested, and size_mode decides what happens to a stray portrait image in a folder of landscape ones.

    Four outputs, and the extra three are more useful than they look: images (the batch), count (how many actually loaded), total_found (how many are in the folder), and filenames (the loaded names, newline-separated). Comparing count against total_found immediately tells you whether your start_index window is doing what you think. Wire filenames into a text node or LC Show Any to see what order you actually got.

    Installing it

    This pack has no requirements.txt at all - no pip install, nothing beyond the torch/numpy/Pillow ComfyUI already has.

    cd ComfyUI/custom_nodes
    git clone https://github.com/lonecatone23/ComfyUI_LC123_nodes.git
    

    Or via Manager: search ComfyUI LC123 Nodes. Restart and look for the [LC123] line in the console.

    Common issues

    "folder not found" with a path you're sure about. The error prints the resolved path, which is the clue: a relative path resolves inside ComfyUI/input/, not relative to wherever your terminal is. Either move the folder under input/ or paste the absolute path.

    "no images found". Either the folder is genuinely empty, or your files aren't in the extension list - .avif, .heic and RAW formats aren't supported.

    start_index past the end. If you start past your last image you get an explicit error naming both numbers rather than an empty batch. Good behaviour, and easier to read than debugging a silent zero-length batch.

    Different sizes are not a bug, they're a choice. Default crop throws away the edges of mismatched images. If you're batching something where the whole frame matters, switch to pad and the black bars will tell you the truth.

    Memory. Every image becomes a float32 tensor in memory before the sampler ever sees it. A folder of 4K PNGs is a lot of RAM even before the VAE encode. max_images is the valve.

    GIFs give you frame one. That's it. For actual video, use a video loader - this is an image-batch loader that happens to tolerate the format.

    CategoryLC123/image

    Inputs (5)

    NameTypeDefaultDescription
    folder_pathSTRINGFull path or a folder name inside ComfyUI/input. Paste it however you like: with or without quotes, / or \.
    start_indexINT00–100000Skip this many images first (0 = start at the first one).
    max_imagesINT00–100000Load at most this many. 0 = all of them. Lower it if you run out of memory.
    size_modeCOMBOcropImages that are not the size of the first one: crop to fill, pad with black, or stretch.
    include_subfoldersBOOLEANfalse—

    Outputs (4)

    NameTypeDescription
    imagesIMAGE—
    countINT—
    total_foundINT—
    filenamesSTRING—