Nodes/ComfyUI-LoadFiles/List Files in Directory
ComfyUI Node

List Files in Directory

ListFilenames (List Files in Directory) — ComfyUI node guide

By daryltucker·Created 2 years ago·Updated 2 years ago· 3
List Files in Directory
    • STRING
    directoryoutput/
    limiter.*.png
    sort
    direction
    splice
    count0
    error

    If you've ever wanted ComfyUI to just look at a folder and tell you what's in it - every PNG in output/, the last five renders, whatever - this is the node that does it. It reads a directory, filters the filenames, sorts them, and hands you back a plain list of strings. Nothing gets loaded into memory. It's not reading pixels or decoding anything; it's reading the file listing, the same thing ls gives you.

    That distinction matters more than it sounds. The classic ComfyUI headache when you try to batch-process a folder is the load-everything-into-RAM node - the WAS "load image list from dir" style loaders that pull all 3GB of your images in at once and choke. ListFilenames sidesteps that entirely. It gives you names, not images. What you do with those names - feed them one at a time into a Load Image node, count them, drive a batch loop - is up to the rest of your graph. It's plumbing, and that's the point.

    Why you'd reach for it

    Directory automation. You've rendered a hundred frames and want the filenames to feed a video assembler. You've got a folder of inputs and want to process the newest one, or the oldest ten, or every file matching a pattern. This is the "give me the manifest" step that most batch workflows quietly need and the native nodes don't really provide.

    It pairs naturally with CountLines from the same pack - ListFilenames gives you the list, CountLines tells you how many there are, and now you can set a batch count or bound a loop index without hand-counting.

    The inputs that actually matter

    The node has a bunch of widgets, but you'll really only touch two or three:

    • directory - the folder to read, default output/. Relative paths resolve against your ComfyUI root, so output/ and input/ are the obvious ones.
    • limiter - a regex to filter filenames, default .*.png. This is a regular expression, not a shell glob, so .*.png means "anything ending in png-ish." Want only PNGs strictly? .*\.png$. Want a prefix? ^frame_.*. If you're getting more (or fewer) files than expected, this widget is almost always the reason.
    • sort / direction - order the results by Name, Date Created, Date Modified, or Size, ascending or descending. (The widget spells them "Acending" / "Decending" - the typos are baked into the node, don't let it throw you.) Sort by Date Modified descending and you've got newest-first, which is usually what you want.

    Then there's splice and count working together: count is how many entries to keep, and splice picks whether you keep them from the Head (first N) or Tail (last N) of the sorted list. Leave count at 0 to keep everything. So "5 newest files" is sort by Date Modified / Decending / count 5 / Head. The error widget toggles what happens on a thin result - No Error stays quiet, Load Count is the stricter mode for when you want the run to fail loudly if the folder doesn't have what you expected. If you're not building validation into an automated pipeline, leave it on No Error.

    Output: a single STRING - the filenames as one newline-separated block. Wire it into CountLines to get a number, into a text display to eyeball it, or into whatever downstream node consumes a path list.

    Installing it

    Two ways, same as any custom node:

    • ComfyUI Manager (the easy way): open Manager, search ComfyUI-LoadFiles, install, restart ComfyUI. Reload the browser tab so the new node shows up in the menu.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/daryltucker/ComfyUI-LoadFiles, then restart ComfyUI.

    No model downloads, no heavy dependencies - this is a small pure-Python utility pack, so it installs clean and doesn't drag transformers or torch versions around with it. That's a genuine relief in a world where half the dependency-conflict horror stories in r/comfyui come from utility packs pulling in things they shouldn't.

    Where people get tripped up

    The number-one issue is the limiter regex. It's easy to assume it's a glob like *.png and get an empty list or a surprise match. Remember it's a regex - test with .* first to confirm the directory is being read at all, then tighten it.

    Second: paths. A relative directory resolves against wherever ComfyUI thinks its root is, which on some installs (portable builds, Docker, cloud runners) isn't where you'd guess. If the list comes back empty and your regex is fine, try an absolute path to confirm the folder is really there.

    And the usual reminder: if the node doesn't appear after install, you didn't fully restart - ComfyUI loads custom nodes at startup, not on the fly. A hard restart plus a browser refresh fixes the "I installed it but it's not in the menu" head-scratcher almost every time.

    CategoryLoadFiles

    Inputs (7)

    NameTypeDefaultDescription
    directorySTRINGoutput/
    limiterSTRING.*.png
    sortCOMBO4 options: Name, Date Created, Date Modified, Size
    directionCOMBO2 options: Acending, Decending
    spliceCOMBO2 options: Tail, Head
    countINT0
    errorCOMBO2 options: No Error, Load Count

    Outputs (1)

    NameTypeDescription
    STRINGSTRING