ComfyUI Node

List Files

Turn a folder into a batch, no Python required

By Q-Bug4·Created about a year ago·Updated about a year ago· 2
List Files
    • file_list
    directory
    file_types*.png,*.jpg,*.jpeg,*.webp
    recursivefalse
    sort_byname
    sort_orderasc
    separator,

    List Files is the quiet utility that makes batch workflows less tedious to build. It reads a directory and hands you back a single comma-separated string of file paths - and because ComfyUI's batch story is built on comma-separated strings, that one output plugs straight into the rest of the pipeline. Pair it with this pack's CrossJoinSelector and you can iterate over a folder of prompts or reference images without hardcoding a single path into your graph.

    How it works

    Point it at a directory, it scans it, filters by extension, sorts, and joins the full paths into one string using the separator you pick (default comma). If directory is left empty, it defaults to ComfyUI's input directory - not your working directory, not the ComfyUI folder, but the folder where you drag-upload things. That's the one bit that surprises people on first use.

    A detail worth knowing from the source: file_types doesn't do real glob matching. The * is stripped and it just checks the file's suffix, case-insensitively. So *.png,*.jpg,*.jpeg,*.webp (the default) works, but so does a bare png,jpg - it's an extension filter wearing a glob costume. recursive walks subdirectories with os.walk, and when it's on, the output includes the full path for every nested file.

    The inputs that matter

    • directory - path to scan; empty defaults to the input folder.
    • file_types - comma-separated extension filters (default *.png,*.jpg,*.jpeg,*.webp).
    • recursive - include subdirectories (off by default).
    • sort_by - name, size, or modified_time. sort_order then flips it asc/desc.
    • separator - default comma; switch to newline or whatever your downstream consumer parses.

    The output is one file_list STRING of full paths, and that's the whole node. It's deliberately simple.

    Installing it

    It comes with the qbug-batch pack, which has zero dependencies - pure standard library plus ComfyUI's built-in folder_paths, no requirements.txt, no models, nothing to go wrong. Install via ComfyUI Manager (search "qbug-batch") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Q-Bug4/comfyui-qbug-batch
    

    Restart ComfyUI and it's under the "filesystem" category.

    Where people get burned

    First, the empty-directory default. If you leave directory blank you'll silently list whatever's sitting in your input folder, which is almost never the folder you meant. Type the full path (e.g. D:\references\poses or /home/you/refs) and it behaves.

    Second, it returns full paths, not bare filenames. Some downstream string consumers want just the name, and if you're not expecting the whole path you'll be confused why your prompt suddenly contains C:\ComfyUI\input\.... Set the directory appropriately or trim downstream.

    Third, the size and modified_time sorts call the filesystem for every file - fine for a folder of a few hundred, but on a huge network share that synchronous scan will make the workflow feel like it's hung. Stick with name sorting unless you need the others.

    The usual workflow shape: ListFiles → CrossJoinSelector (same pack) → a prompt or an image loader, then queue the batch. It's not flashy, but once you've got it in a graph you'll keep reaching for it.

    Categoryfilesystem

    Inputs (6)

    NameTypeDefaultDescription
    directorySTRING
    file_typesSTRING*.png,*.jpg,*.jpeg,*.webp
    recursiveBOOLEANfalse
    sort_byCOMBOname3 options: name, size, modified_time
    sort_orderCOMBOasc2 options: asc, desc
    separatorSTRING,

    Outputs (1)

    NameTypeDescription
    file_listSTRING