读取文件列表
Filter a folder's files by keyword and format, with AND/OR/negation
- input_list
- listin
- filtered_results
- listout
- file_count
LamReadFileList (读取文件列表) is a file-filtering utility: point it at a folder, give it a keyword and a file-format filter, and it returns the matching file paths - as a formatted list, a raw list, and a count. The workflow niche is automation loops: batch-processing a directory of images or audio, feeding filenames into iteration nodes, or building a "process everything matching this pattern" pipeline.
The filtering syntax is where it gets interesting, because it's more capable than most of these utilities:
/separates multiple keywords or formats (any-of).- A space between words means AND -
car sunsetmatches files containing both. |is OR within a token -jpg|pngmatches either extension.- A leading
!negates -!draftexcludes files with "draft" in the name. *is a wildcard (and the defaultkeywords1andfile_formats1are*= match everything).
So dog|cat indoor in keywords1 means "filenames containing indoor AND (dog OR cat)." Handy once you internalize it.
Inputs
- keywords1 (required) - the filename filter. Default
*. - folder_path - the folder to scan. If missing, it's created (side effect worth knowing). If empty, the node falls back to the list inputs.
- input_list / listin - alternative sources: filter an existing list instead of a folder (
listinwins overinput_listoverfolder_path). - file_formats1 - extension filter,
/separated. Default*. - dummy_parameter - a harmless INT that exists so you can trigger re-execution.
Outputs
- filtered_results - the matches as one newline-joined formatted string in a list.
- listout - the raw unfiltered... no wait, the raw filtered list of file paths.
- file_count - how many matched.
It's an output node, and IS_CHANGED forces a re-run every execution - the node always reflects the current state of the folder, which is what you want for loops but means no caching.
Install
Part of the ComfyUI_Lam pack:
cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam
or via ComfyUI Manager, then the README's install + 修改文件 steps. Pure Python - no models.
Gotchas
The dummy_parameter is a workaround for ComfyUI's caching: bump it to force the node to re-run even when its other inputs look unchanged. And the "creates the folder if it doesn't exist" behavior is a footgun if you typo a path - you'll silently get an empty list instead of an error while a new empty directory appears somewhere. Filters are case-insensitive by design, which surprises people coming from Linux's case-sensitive filesystem habits.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| keywords1 | STRING | * | — |
| folder_pathopt | STRING | — | |
| input_listopt | LIST | — | |
| listinopt | LIST | — | |
| file_formats1opt | STRING | * | — |
| dummy_parameteropt | INT | 0 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| filtered_results | LIST | — |
| listout | LIST | — |
| file_count | INT | — |