mkdir-badger
Make ComfyUI create folders for you mid-workflow
- STRING
ComfyUI will happily write files into folders that don't exist yet - it'll just error out when a save node can't find the path. mkdir-badger exists to stop that from happening: it creates a directory on demand, inside the graph, and hands the resulting path back to you as a string so the rest of your workflow knows where things are.
The real use case is dynamic output organization. Pair it with a GetUUID or a seed value and you can generate a fresh folder per run - outputs/run_<uuid>/ - then feed that path into a Save Image node's filename field. Keep the same pattern every day and your hard drive stops looking like a war crime. It also pairs naturally with getParentDir-badger in the same pack, which resolves the parent of any path, so you can build folder trees in the graph without hardcoding anything.
The mechanism is straightforward Python: it takes your input path, calls os.path.abspath() on it, joins your new folder name onto it, and creates it with os.mkdir() - but only if it doesn't already exist. Then it returns the new absolute path.
You set two inputs:
- dir_path - the parent folder, as a string. Can be an absolute path or a relative one.
- new_dir - the name of the folder to create inside it (default
newdir).
The single output is the created path as a STRING, which is what you wire into save nodes and anything else that wants a path.
Three gotchas worth knowing. First, os.mkdir() only creates one level - if the parent path itself doesn't exist, it fails rather than creating the whole chain like mkdir -p would. Create parents first, or pass a path that already exists. Second, a relative dir_path resolves against ComfyUI's working directory, which isn't always where you think it is; absolute paths are the safer habit. Third, because it checks existence before creating, it's effectively idempotent - run it twice and you get the same path back, no error, which is usually what you want in a rerun-heavy workflow.
Install is the standard deal: ComfyUI Manager, search ComfyUI_BadgerTools, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/AbyssYuan0/ComfyUI_BadgerTools
It's a small node from a small personal pack - the README is literally a three-line Chinese note about the author's own utilities - but for anyone who saves organized output, it's quietly one of the more useful five-liners around. It won't change your image quality. It'll just keep your files from becoming a disaster.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dir_path | STRING | — | |
| new_dir | STRING | newdir | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |