CGA_ListSubfolders
Who's in this folder? This node counts them and hands you the paths
- subfolders
- subfolder_count
- folder_name
If you're building a workflow that processes a folder of subfolders - a dataset split into classes, a stack of character folders, a directory tree you want to loop over - the first thing you need is a list of what's actually in there. CGA_ListSubfolders gives you that in one node: all the immediate subfolders, how many there are, and the name of the folder you pointed at.
It's a tiny filesystem utility and it knows its job. Give it a path, get back three outputs.
Inputs and outputs
- folder_path (STRING) - the path you want to inspect. A plain text field, not a file browser.
Outputs:
- subfolders (STRING) - a list of the full paths of every subfolder, one level deep.
- subfolder_count (INT) - how many there are.
- folder_name (STRING) - the base name of the input path itself (the last segment), handy for labeling batch output.
It's marked as an output node, so it can display its results right on the canvas - useful when you're just checking what a path resolves to.
The behavior that's both nice and sneaky
Give it a bad path and it doesn't crash - it returns an empty list, a count of zero, and an empty string. That's friendly in the sense that a typo won't nuke your run, but it also means a wrong path fails silently and your downstream loop just iterates over nothing. If you're wondering why nothing processed, check the count.
Two more things to know. It's non-recursive: only the immediate children of the folder, no digging deeper. And this is the odd one out in the pack - while the other seven nodes live under the CGAnimittaTools menu group, this one is categorized as custom, so look for it there.
Where it fits
This is the feeder node for the pack's batch story. Pair it with a loop and a CGA_TxtReaderNode pointed at whatever subfolder the loop selects, and you can walk a whole directory tree of prompt files or captions without hardcoding a single path. Its sibling CGA_ExtractFromList can pull one subfolder path at a time by index inside the loop.
Install
Part of ComfyUI_CGAnimittaTools, installable from ComfyUI Manager by searching the pack title, then restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/cganimitta/ComfyUI_CGAnimittaTools
No models, no downloads, no real dependencies - the pack's requirements.txt is just torch, numpy, and pathlib, which ComfyUI already has.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| subfolders | STRING | — |
| subfolder_count | INT | — |
| folder_name | STRING | — |