Nodes/ComfyUI-JDCN/JDCN_AnyFileListRandom
ComfyUI Node

JDCN_AnyFileListRandom

Random files from a folder, batch-sized, seed-controlled

By daxcayΒ·Created 2 years agoΒ·Updated about a year agoΒ· 159
JDCN_AnyFileListRandom
    • PathList
    • PathNames
    • Total
    β—„folder_pathundefinedβ–Ί
    β—„filter_byβ–Ύβ–Ί
    β—„extensionβ–Ύβ–Ί
    β—„random_seed1β–Ί
    β—„seed_changeβ–Ύβ–Ί
    β—„batch_size1β–Ί
    β—„deep_searchfalseβ–Ί

    JDCN_AnyFileListRandom is JDCN_AnyFileList with a dice roll: same folder scanning and filtering, but instead of returning every match, it returns a random batch of paths, controlled by a seed. If you've ever wanted to sample a handful of random images from a reference folder, or randomize which training/reference files a run picks, this is the node.

    How it works

    It shares AnyFileList's inputs - folder_path, filter_by, extension, deep_search - then adds the selection controls:

    • random_seed - the seed for the random pick. Same seed, same selection. Change it, get a different batch.
    • seed_change - fixed, increment, decrement, or random. This tells you how the seed should behave across queue runs. One honest caveat: like the Change dropdown on JDCN_AnyFileSelector, this is largely a label - the node computes the selection from the current seed value, so the automatic incrementing depends on you driving the seed (via a counter or the random option upstream). Treat it as "how I intend to move the seed," not "the node will do it for me."
    • batch_size - how many files to select per run.

    Outputs: PathList (the random subset), PathNames, and Total. One quirk straight from the source: only PathList is actually the randomized subset - PathNames and Total reflect the full matched folder, not your random pick. So if you wire Total into a loop expecting the batch size, you'll get the whole count instead. Keep that in mind and grab the count from PathList's length instead.

    When you'd reach for it

    • Random reference images for img2img or IP-Adapter runs - a different mood every queue.
    • Randomly sampling a subset of a large training/reference set without writing a script.
    • Batch variation: set batch_size to 3, run, and feed the selected paths into JDCN_BatchImageLoadFromList for a random trio.

    Installing it

    Part of ComfyUI-JDCN:

    • ComfyUI Manager β†’ Install Custom Node β†’ search JDCN β†’ install ComfyUI-JDCN β†’ restart.
    • Or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-JDCN.git
    cd ComfyUI-JDCN
    pip install -r requirements.txt
    

    Restart; it's under πŸ”΅ JDCN πŸ”΅. Only dependency is piexif, no models.

    Common issues

    Same path typos and folder-not-found behavior as AnyFileList (empty lists + a console message). The subtle one is the Total/PathNames mismatch above - if your workflow counts on those matching the random batch, verify against the actual PathList. And for reproducibility, commit to a seed; random in seed_change is fun for exploration and a nightmare for "but it worked yesterday."

    CategoryπŸ”΅ JDCN πŸ”΅

    Inputs (7)

    NameTypeDefaultDescription
    folder_pathSTRINGundefinedβ€”
    filter_byCOMBO7 options: *, images, audio, video, text, tensors, +1
    extensionCOMBO153 options: *, .latent, .ckpt, .pt, .bin, .pth, +147
    random_seedINT11–18446744073709550000β€”
    seed_changeCOMBO4 options: fixed, increment, decrement, random
    batch_sizeINT11–9999β€”
    deep_searchBOOLEANfalseβ€”

    Outputs (3)

    NameTypeDescription
    PathListSTRINGβ€”
    PathNamesSTRINGβ€”
    TotalINTβ€”