getParentDir-badger
Go up one directory level — the path helper for workflows that build paths
- STRING
getParentDir-badger does one boring, useful thing: give it a directory path and it returns the parent directory. /data/runs/hero_v2/frames → /data/runs/hero_v2. It's os.path.dirname as a node, and it exists because the pack's author builds file paths inside the graph instead of typing them once - and once you start doing that, "go up one level" becomes a move you need constantly.
Say a node hands you back a deep path. FrameToVideo-badger returns the full path to your new mp4; VideoToFrame-badger returns a frame folder buried in the pack's own directory. You want to do something with the containing folder - make a subfolder next to it, delete it, name an output after it. That's a getParentDir call. It's the upward half of the pack's file-navigation trio: GetDirName-badger reads the folder's own name, this one walks up to the folder that contains it, and mkdir-badger (not covered here) makes new ones.
The genuinely practical pattern is path assembly without hardcoding. Instead of typing /absolute/path/to/your/stuff into three different nodes, you get one base path from somewhere, then build relative to it: getParentDir up a level, mkdir down into a new subfolder, deleteDir to clean up. Every step is a node, every step is inspectable, and you never hardcode a second path that silently drifts out of sync with the first.
How it works
Straight Python: os.path.abspath() then os.path.dirname(). Relative paths are resolved to absolute first, so the answer is deterministic no matter what directory ComfyUI was launched from. One input, one output, no settings, no edge-case dropdowns.
Inputs and outputs
- dir_path - a STRING path.
One output: a STRING, the parent directory. Feed it the root of a drive and it returns that same root (dirname at the top of a filesystem is a no-op) - the only real quirk, and you're unlikely to hit it.
Installing it
In ComfyUI_BadgerTools: ComfyUI Manager → search "BadgerTools" → install, or
cd ComfyUI/custom_nodes
git clone https://github.com/AbyssYuan0/ComfyUI_BadgerTools
Restart after install. No model files. Standard pack tax: the heavy requirements (moviepy, open_clip_torch, sentence_transformers, scikit-image, three opencv variants) install and import at startup even though this node is os.path in a box.
Gotchas
- It works on paths, not files. Feed it
/data/out/img.pngand it returns/data/out, because dirname doesn't distinguish files from folders - that's arguably a feature (it's how you get the folder containing a file), but it surprises people who thought they'd get the file's folder only if the path ends in a slash. It doesn't care about the slash. - No existence checks. The parent is returned whether or not it exists. Pure string math.
There's no community discussion of this node - it's a personal-pack helper with a two-line README. It's also the kind of node you'll only miss the day you're hand-typing the third near-duplicate absolute path into a graph and wondering why this keeps being a pain.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dir_path | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |