Nodes/ComfyUI_Lam/读取文件列表
ComfyUI Node

读取文件列表

Filter a folder's files by keyword and format, with AND/OR/negation

By yanlang0123·Created 2 years ago·Updated about a month ago· 76
读取文件列表
  • input_list
  • listin
  • filtered_results
  • listout
  • file_count
keywords1*
folder_path
file_formats1*
dummy_parameter0

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 sunset matches files containing both.
  • | is OR within a token - jpg|png matches either extension.
  • A leading ! negates - !draft excludes files with "draft" in the name.
  • * is a wildcard (and the default keywords1 and file_formats1 are * = 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 (listin wins over input_list over folder_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.

Categorylam

Inputs (6)

NameTypeDefaultDescription
keywords1STRING*
folder_pathoptSTRING
input_listoptLIST
listinoptLIST
file_formats1optSTRING*
dummy_parameteroptINT0

Outputs (3)

NameTypeDescription
filtered_resultsLIST
listoutLIST
file_countINT