Get Subdirectories (Mikey)
List a folder's subfolders for batch/per-folder pipelines
- subdirectories
A small directory-listing utility that earns its place if you organize anything into per-folder batches - say, a characters/ directory with one subfolder per person, or a styles/ directory with one subfolder per look, and you want your graph to know what those subfolder names actually are without you hardcoding a list somewhere. Get Subdirectories reads a path and hands back the names of whatever folders live directly inside it.
It's most useful paired with other directory-driven nodes in the pack, like Batch Load Images or Load Image Based on Number (Mikey siblings not covered in this article), where you'd otherwise have to type each subfolder name in by hand to process them one at a time. Instead, point Get Subdirectories at the parent folder, and let the list of names drive the rest of the pipeline.
The one input that matters is directory - a string path, defaulting to the placeholder "base_directory" (which you'll need to replace with a real path). The output is subdirectories, a STRING list - one entry per subfolder found directly inside the given path.
Because the output is a list, this is worth understanding before you wire it up: ComfyUI treats list outputs as something to fan out over, meaning anything downstream that consumes this output will typically run once per subdirectory name rather than once total. That's usually exactly what you want if you're building a per-folder batch pipeline, but it can be surprising the first time you see a downstream node execute multiple times when you were expecting one run.
Installing it
Comes with the full Mikey Nodes pack. Through ComfyUI Manager, search "Mikey Nodes." Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/bash-j/mikey_nodes
Restart ComfyUI. No models or extra dependencies needed - it's a directory listing operation.
Common issues
The most common mistake is leaving directory at its literal default value, "base_directory", which isn't a real path - you need to point it at an actual folder on disk before running the graph, or it'll fail to find anything. Beyond that, remember this only returns folders one level deep; it doesn't recurse into nested subfolders-of-subfolders. If your structure goes deeper than one level and you need the whole tree, you'll need to chain this node or handle the deeper levels separately, since this node's job is deliberately scoped to a single directory listing rather than a full recursive walk.
It's also worth being deliberate about ordering if it matters to your pipeline - this node just returns whatever the filesystem hands it, and depending on your OS that's not guaranteed to be alphabetical. If you're relying on subdirectory order to line up with something else (say, matching folder names against a separate ordered list elsewhere in your graph), sort or otherwise normalize the list downstream rather than assuming it'll come back in the order you expect. And since the path is a plain string with no browse button, it's easy to typo a folder name - if the output list comes back empty, check for a trailing slash or case mismatch before assuming the node is broken; on case-sensitive filesystems, a folder named Characters won't match a path typed as characters.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | base_directory | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| subdirectories | STRING | — |