⛧Get Subfolders
List what's already on disk, so the rest of the pipeline knows
- subfolders
Here's a small one that earns its place through context. In this pack's Wan loop workflows, several nodes need to know what's already on disk: Load Image Folders wants the list of numbered folders to load, Save Latent And Images wants the list of existing folders so it can skip work that's already done. Get Subfolders is the little helper that answers that question - it reads a directory and returns every subfolder name as a single newline-separated string.
That string format is deliberate. It's exactly what folders_str expects on Load Image Folders and Save Latent And Images. So the flow becomes: Get Subfolders scans your project folder → its output feeds the folders_str input of the load/save nodes → they parse the same newline-separated convention. The whole numbered-folder loop is glued together by this one string shape.
Inputs and output
Just two inputs:
- folder_path - the directory to scan. An absolute path;
~is expanded. The placeholder literally asks for/path/to/folderor a Windows path. - sort_alphabetically - default
true, and it sorts case-insensitively (sort(key=str.lower)), so10sorts after09the way you'd hope... well, alphabetically, which for a folder set named01–99happens to be numeric order anyway.
The single output is subfolders: names joined with \n, or an empty string when the folder is empty. No hidden behavior.
How it behaves when things go wrong
Notably, this node doesn't raise - it returns error text as the output string. Point it at a missing path and you get Error: Path does not exist: ...; a file instead of a directory, a permission error, anything, all come back as a string starting with Error:. That's a double-edged design: nothing ever crashes your queue, but if you pipe that straight into a folders_str input that's parsing for two-digit folder names, an error string is going to be ignored silently rather than reported. If a downstream node looks like it's doing nothing, check this node's console output - the actual error is printed there with the [GetSubfolders] prefix.
Install
It's part of ComfyUI-HeresyNodes, a small personal pack by heresyCoder aimed at file management around Wan video generation:
cd ComfyUI/custom_nodes
git clone https://github.com/heresyCoder/ComfyUI-HeresyNodes
Restart ComfyUI afterward (or install via Manager by searching "ComfyUI-HeresyNodes"). There's no requirements.txt and no model download - everything it needs ships with ComfyUI.
When you'd actually reach for it
The honest use is inside the pack's own loop pattern: before a save run, Get Subfolders tells Save Latent And Images which numbered sections already exist, so it skips them instead of duplicating. Before a load run, it feeds Load Image Folders the folder list to read back. As a standalone, it's a directory listing you could just as easily do in a terminal - the value here is that the listing is in the graph, live, at queue time, so the workflow adapts to whatever a previous run left behind. That's the whole pitch, and it's a good one.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | — | |
| sort_alphabeticallyopt | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| subfolders | STRING | — |