Nodes/ComfyUI-TinyBee/Enumerate Files In Folder
ComfyUI Node

Enumerate Files In Folder

Turn a directory into a wire — with one annoying catch

By TinyBeeman·Created about a year ago·Updated 16 days ago· 1
Enumerate Files In Folder
    • filepath_list
    ◄folder_path►
    ◄file_extension.zip►
    ◄exclude_list►

    What it's for

    ComfyUI is very good at "one prompt, one image" and quite bad at "here are 40 files, do something to each". The core loaders make you pick a single file off a dropdown. Enumerate Files In Folder is the missing half of a folder-processing loop: hand it a path, get back a real list of absolute file paths you can drive other nodes with.

    It's the upstream half of this pack's own idiom - enumerate a folder of .zip bundles, then feed the list into something that consumes it. Which is why the default extension is .zip and not .png.

    How it works

    The mechanism is os.listdir, so a few facts follow immediately and matter:

    • It is not recursive. Subfolders are not walked. Point it at a folder, you get that folder's files.
    • The extension filter is a case-insensitive endswith, and it's forgiving about the dot: zip and .zip both work, because a missing leading dot gets added for you.
    • exclude_list is a substring test against the filename only - not the full path - and it's case-sensitive. Wire a string in (it's an optional forced input, so it's a socket, not a text box) and any file whose name contains it is dropped. That's how you skip _mask.png, _preview or a specific subject tag without renaming anything on disk.

    The catch: your folder has to live inside ComfyUI

    This one trips up basically everyone the first time. Before listing anything, the node checks that the folder is inside your ComfyUI installation directory, and if it isn't it prints folder_path <your path> is not allowed. to the console and stops.

    So D:\datasets\raw or /mnt/bigdisk/training is rejected. ComfyUI's own convention wants your data under ComfyUI/input or ComfyUI/output anyway, so the usual fix is either a symlink/junction pointing into ComfyUI, or just accepting that you move the files. If you see that console line, that's the whole story - it's not a permissions problem, and it isn't the extension filter.

    Inputs and outputs

    folder_path (STRING) and file_extension (STRING, default .zip) are the required pair. exclude_list is the optional third. The one output is filepath_list, a list of strings.

    Because it's a list output, this node is a fan-out point: wire it into a node that isn't declared as a list-input and ComfyUI will run that node once per entry, which is how a single save or decode becomes a batch over the whole folder. This is also the natural partner pair with the rest of the pack - Enumerate Files In Folder → Load Image Dict From Zip, and Enumerate Files In Folder → Filter Path List when you want an allowlist on top.

    Installing it

    Ships in ComfyUI-TinyBee, category 🐝TinyBee/Lists. No models, no compiled extensions, no dependency drama - the README notes every dependency is Python standard library.

    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    Or search ComfyUI-TinyBee in ComfyUI Manager and restart.

    Where people get burned

    Adding a file to the folder and re-queuing does nothing, because this node doesn't opt out of ComfyUI's cache - it's keyed on its inputs, and its inputs didn't change. Change the path to something else and back, or make any widget edit that dirties the node. Same story if you edit the file contents rather than the filenames.

    An empty result usually means one of three things, in this order: the path isn't a directory (a typo'd path returns an empty list rather than shouting), the extension doesn't match because your files are .PNG and you typed .png - that part's actually fine - or the exclusion substring is eating everything. Check the exclusion first; it's the one that fails silently and completely.

    Category🐝TinyBee/Lists

    Inputs (3)

    NameTypeDefaultDescription
    folder_pathSTRING—
    file_extensionSTRING.zip—
    exclude_listoptSTRING—

    Outputs (1)

    NameTypeDescription
    filepath_listSTRING—