get_folder_info(mki-获取文件夹文件信息)
List, sort, and filter files from inside the graph
- output_string
- output_list
- nth_item
- tree_structure
- file_count
- has_files
- error_message
ComfyUI is great at reading files it knows about - checkpoints, LoRAs, images in its model folders - and useless at reading arbitrary folders. get_folder_info_makki (display name "get_folder_info(mki-获取文件夹文件信息)") is the exception: you give it any folder path and it scans it, filters it, sorts it, and hands you back a filename, a count, or a tree view - all as graph data you can wire into other nodes.
The realistic use case: batch processing. You point it at a folder of input images, it tells you the Nth filename, and you feed that into a loader. Or you use file_count as the loop bound for processing a folder you didn't generate in ComfyUI.
The inputs
There are a bunch, and they're all straightforward:
- folder_path - the folder to scan (e.g.
C:/Users/MyUser/Documentsor/home/user/documents). Required. - file_index - which file to return in the
nth_itemoutput (1-based, sorted by your chosen order). - output_full_path -
falsereturns filenames,truereturns full paths. - include_subfolders - recurse into subfolders.
- file_filter - glob, e.g.
*.txtorimage*.png. - file_types -
all,image,text,audio, orvideo(extension-based). - sort_by -
name,date_modified, orsize. - sort_order -
ascending/descending. - limit - cap the returned list (0 = no limit).
- regex_filter - a regex like
^image.*\.png$for when a glob isn't enough.
The outputs
Seven, which is a lot for a utility node, but each is a different way to look at the same scan:
- output_string - all files joined into one string, one per line.
- output_list - the same files as a proper
LISTyou can feed into list-consuming nodes. - nth_item - the single file at
file_index. - tree_structure - a formatted ASCII tree of the folder (this is the nice one with include_subfolders - it renders subfolders as nested branches).
- file_count - how many files matched.
- has_files - a boolean, handy for conditional logic.
- error_message - non-empty when the path doesn't exist or isn't a folder.
Gotchas
file_indexis 1-based, and out of range returns the string"Index out of range."- which will then flow into whatever you wirednth_itemto, so check it if you're feeding loaders.- Filtering is strict about extensions when you use
file_types. An uppercase.PNGmay not match the lowercase extension list - setfile_typestoallif you're seeing mysteriously empty scans. - A bad path doesn't crash - it returns empty outputs plus a readable
error_message. That's the node being polite; wireerror_messagesomewhere visible if you're scripting.
Installing
It's in ComfyUI-MakkiTools:
cd ComfyUI/custom_nodes
git clone https://github.com/MakkiShizu/ComfyUI-MakkiTools
cd ComfyUI-MakkiTools
pip install -r requirements.txt
Restart ComfyUI. Nothing heavy in here - it's plain os walking under the hood. For anything that needs a filename from an arbitrary folder inside your graph, this is the node.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | 要扫描的文件夹路径,例如 'C:/Users/MyUser/Documents' 或 '/home/user/documents' The folder path to scan, e.g. 'C:/Users/MyUser/Documents' or '/home/user/documents' | |
| file_index | INT | 11–1000 | 要获取的第几个文件名(按名称排序),从1开始计数 The index of the file to get (sorted by name), counting from 1 |
| output_full_path | BOOLEAN | false | 如果为True,输出完整路径;否则只输出文件名 If True, output full path; otherwise output only filename |
| include_subfolders | BOOLEAN | false | 是否包含子文件夹中的文件 Whether to include files in subfolders |
| file_filter | STRING | * | 文件筛选器,例如 '*.txt' 或 'image*.png' File filter, e.g. '*.txt' or 'image*.png' |
| file_types | COMBO | all | 文件类型筛选 File type filter |
| sort_by | COMBO | name | 排序方式 Sort method |
| sort_order | COMBO | ascending | 排序顺序 Sort order |
| limit | INT | 0 | 限制返回的文件数量,0表示无限制 Limit the number of files returned, 0 means no limit |
| regex_filter | STRING | 正则表达式筛选,例如 '^image.*\.png$' Regular expression filter, e.g. '^image.*\.png$' |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| output_string | STRING | — |
| output_list | LIST | — |
| nth_item | STRING | — |
| tree_structure | STRING | — |
| file_count | INT | — |
| has_files | BOOLEAN | — |
| error_message | STRING | — |