Nodes/ComfyUI-LoadAnim-Adv/List Files From Directory
ComfyUI Node

List Files From Directory

The directory scanner without the heavy lifting

By SineSwiper·Created 7 months ago·Updated 7 months ago· 0
List Files From Directory
    • filenames
    directory
    file_list_cap0
    file_start_index0
    include_subfoldersfalse
    valid_extensionsjpg,jpeg,png,webp,gif,tga
    sort_method

    Most loaders try to do too much. They scan a folder and load every file, and half the time you don't want that - you want to look at what's there first, or feed paths into some other node. List Files From Directory strips the "load" part out and just hands you the file list. It's the under-the-hood scanner of SineSwiper's LoadAnim-Adv pack, exposed as its own node because a bare list of paths is genuinely useful on its own.

    What it does

    Give it a directory path and it returns filenames: a list of matching file paths, sorted and filtered the way you ask. No image decoding, no tensors, no VRAM touched. It shares its guts with the big batch loader - Load Images/Videos From Directory literally calls this same scan function - but it stops at names.

    Where you'd actually use it

    Two patterns keep coming up:

    1. Batch-loop plumbing. The output is a list of strings, and ComfyUI will run a downstream node once per item when it doesn't support lists. That means you can chain this into a path-based loader (like Load Image/Video From Path) and process every file in a folder without writing a single loop node yourself. The tooltip says it plainly: "Input nodes that do not support lists of files will be executed one-at-a-time."
    2. Inspecting before loading. Wire filenames into a text preview node, check you're scanning the right folder and the right extensions, then commit to the heavy loader. Cheaper than discovering your sort order was wrong after loading 400 files.

    Inputs

    • directory - the only required field.
    • file_list_cap - max filenames to return. 0 = no limit.
    • file_start_index - skip this many from the front of the sorted list.
    • include_subfolders - recurse. Off by default.
    • valid_extensions - comma-delimited, default jpg,jpeg,png,webp,gif,tga. Toss in mp4,mov for videos.
    • sort_method - None, Alphabetical (ASC/DESC), Numerical (ASC/DESC), Datetime (ASC/DESC). For frame sequences, Numerical is the whole point: natural sorting puts frame2 before frame10, which alphabetical sorting gets wrong.

    Installing

    Same as the rest of the pack - ComfyUI Manager (search "LoadAnim"), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/SineSwiper/ComfyUI-LoadAnim-Adv.git
    

    Restart ComfyUI. The pack's only dependencies are torch, numpy, and Pillow, and nothing here loads models.

    Gotchas

    • It errors out if the directory doesn't exist or contains no matching files. That's by design - a silently-empty list is how you end up debugging a pipeline that never ran.
    • The list respects your sort order, so file_start_index is meaningless without picking a sort_method. Leave sort at None (filesystem order) and your "start at 5" is starting at whatever order the OS returned.
    • One output, one job. If you need the actual frames, this is a building block, not the destination - feed filenames into a path loader and let the graph do the rest.

    It's not the flashiest node in the pack, but it's the one that makes clean batch workflows possible without a pile of hacky workarounds.

    CategoryLoadAnimAdv/Loaders

    Inputs (6)

    NameTypeDefaultDescription
    directorySTRINGAbsolute or relative path to the image directory.
    file_list_capoptINT0Maximum amount of files to list out. Zero means no maximum.
    file_start_indexoptINT0Index (zero-based) to start listing files, based on the collected filenames from the directory search.
    include_subfoldersoptBOOLEANfalseControls whether to recursively search for files within subdirectories.
    valid_extensionsoptSTRINGjpg,jpeg,png,webp,gif,tgaComma-delimited list of file extensions to search for.
    sort_methodoptCOMBOControls how to sort the image filename list.

    Outputs (1)

    NameTypeDescription
    filenamesSTRINGThe list of filenames that match the inputs specified. Input nodes that do not support lists of files will be executed one-at-a-time.