⛧Delete Numbered Folders
The clean-slate node for loop renders
- status_log
If you've ever run a chunked video workflow twice, you know the ritual: the first run's 01_L/, 02_L/, 03_L/ folders are still in your output directory, and run two quietly mixes new frames in with stale ones. Delete Numbered Folders exists to fix exactly that - it sweeps the numbered output folders inside a project so your next pass starts clean.
It's the cleanup half of this pack's loop pipeline. The save nodes write each section of a Wan video into a two-digit folder (01, 02, ... or 01_L), and this node deletes them before you re-render. Think of it as the "empty the staging area" button, except it lives in the graph and runs when you queue.
What you give it
Only two inputs matter here, which is the whole point of the node:
- relative_target_path - a path relative to your ComfyUI output folder. You must specify a nested folder; the node refuses to run against the output root itself. So
my_project/renders, not an absolute path and not a bare/. - start_index - how much to keep.
0deletes every matching folder.5keeps01–04and deletes everything05and up. That's the killer feature for the "keep the take I liked, trash the rest" workflow.
The output is a single status_log string telling you what got deleted (or why it refused), which you can shove into a Show Text node or just read in the console.
How it actually works
The node resolves your relative path against the output directory, then deletes any subfolder whose name matches the pattern NN or NN_L - exactly two digits, optionally with an _L suffix. That _L is how this pack marks latent-containing sections, so it catches both the image batches and their latent siblings.
The interesting part is the safety wiring, and it's genuinely well done for a utility node:
- Empty path → error. It won't even let you try to nuke the output root.
- A path resolving to the output root itself (via
.or empty tricks) → refused. - A path that escapes the output directory (
../..anywhere) → refused with a security violation message. - A directory that doesn't exist → skipped, not crashed.
So the worst case is "nothing happened and there's a message about it," which is the right failure mode for a node that calls shutil.rmtree on your disk. start_index is an INT capped at 0–99, matching the two-digit folder scheme.
Installing it
This ships inside ComfyUI-HeresyNodes, a small pack by heresyCoder that's mostly personal support nodes for Wan video loop workflows. Grab it the usual ways:
cd ComfyUI/custom_nodes
git clone https://github.com/heresyCoder/ComfyUI-HeresyNodes
Then restart ComfyUI. ComfyUI Manager can also install it - search for "ComfyUI-HeresyNodes". There are no model downloads and no extra Python dependencies; everything it needs comes with ComfyUI itself.
Where people get burned
The number one footgun is forgetting the whole thing is scoped to the output directory. Type an absolute path into relative_target_path and you'll get a security refusal, not a deletion. Also remember that start_index means "keep everything below this number," which reads backwards from how you'd expect a delete function to work - the brief spells it out: 0 deletes all, 5 keeps 01–04. Test with start_index at a high value once before you trust a cleanup run, and don't wire it to delete your project root - the node won't let you anyway.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| relative_target_path | STRING | — | |
| start_index | INT | 00–99 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| status_log | STRING | — |