Nodes/ComfyUI-Tlant-Toolkit/Load File Batch (Tlant)
ComfyUI Node

Load File Batch (Tlant)

Pick a file from a folder — by index, in order, or at random

By Tlant·Created 4 months ago·Updated 2 months ago· 0
Load File Batch (Tlant)
    • file_path
    • filename_text
    • filename_stem
    • folder_path
    • extension
    • index
    • count
    ◄mode▾►
    ◄seed0►
    ◄index0►
    ◄labelBatch 001►
    ◄path►
    ◄extensions►
    ◄recursivefalse►
    ◄filename_text_extension▾►

    Batch processing always starts with the same boring problem: getting the right file, in the right order, out of a folder. Load File Batch (Tlant) is the node that solves it in three different ways at once. Give it a folder path and it picks exactly one file - by a fixed index, by a persistent counter that walks through the folder one queue run at a time, or by a seed-stable random choice - and hands you the absolute path plus all the filename metadata you'll want downstream.

    The mode dropdown is the whole personality of the node:

    • single_file - always the file at index in the folder. Deterministic, good for a fixed reference image or a known test file.
    • incremental_file - the batch-workhorse mode. Each run advances a counter, so a folder of 50 source videos gets processed 1, 2, 3… in order, wrapping around when it hits the end. The counter lives in a state file (tlant_toolkit_state.json) inside the pack's folder, keyed by your label plus the folder and extension settings - which is how you keep several independent batches going without them stepping on each other.
    • random - a seed-stable random pick via random.Random(seed). The seed widget has a control after generate toggle, so you can lock one file in or roll a new one each run.

    The other inputs are the ones you'll actually touch: path (the folder), extensions (a space-or-comma separated filter like png, jpg; empty means all files), recursive (search subfolders), and filename_text_extension - true gives you the filename with its extension, false gives you the bare stem.

    Outputs cover the practical cases:

    • file_path - absolute path, ready to feed a Load Image, Load Video, or any path-taking node.
    • filename_text, filename_stem, extension, folder_path - the pieces for naming saves or building captions.
    • index and count - which file you're on and how many there are, handy for progress tracking or folder-based numbering.

    Install

    ComfyUI Manager → search ComfyUI-Tlant-Toolkit → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Tlant/ComfyUI-Tlant-Toolkit
    

    Restart ComfyUI. Empty requirements.txt, no model downloads - one of the safest kinds of installs there is.

    The gotchas that actually bite

    The incremental counter is stateful, which surprises people. It's stored on disk in the pack directory, so a git pull of the pack won't reset it, but changing the label, path, or extensions creates a fresh counter - rename your folder mid-batch and you'll start over. Also, both incremental_file and random always re-execute (ComfyUI's cache is deliberately defeated), which means everything downstream reruns each queue. That's usually what you want in a batch; just don't loop it upstream of an expensive sampler and expect caching to save you. And if a folder has no matching files, the node raises rather than silently returning garbage - add the right extension filter or double-check the path.

    CategoryTlant Toolkit/IO

    Inputs (8)

    NameTypeDefaultDescription
    modeCOMBO3 options: single_file, incremental_file, random
    seedINT00–18446744073709550000—
    indexINT00–150000—
    labelSTRINGBatch 001—
    pathSTRING—
    extensionsSTRING—
    recursiveBOOLEANfalse—
    filename_text_extensionCOMBO2 options: true, false

    Outputs (7)

    NameTypeDescription
    file_pathSTRING—
    filename_textSTRING—
    filename_stemSTRING—
    folder_pathSTRING—
    extensionSTRING—
    indexINT—
    countINT—