Clear Directory
A pass-through node that nukes a folder for you
- any_input
- any_output
Every once in a while a pack ships a utility that's so dull you forget it exists - and then you need it. Clear Directory deletes everything inside a folder you name, as a node, so it can run as part of a workflow instead of you SSH-ing in and rm -rf-ing by hand. It lives in the Aryan185/ComfyUI-ExternalAPI-Helpers pack, which is mostly API wrappers, so this one stands out as the only node here that touches your local filesystem.
Where it earns its keep: batch jobs that write into a fixed output folder. If you're rendering a run of images or Tripo models into the same directory over and over, you can drop this node at the front of the graph, point it at that folder, and every run starts clean instead of accumulating _0001_, _0002_… leftovers. It's also handy for clearing temp/scratch dirs before a workflow that scans a folder for inputs.
How it works
Read the name carefully: it clears a directory's contents, not the directory itself. The node expands the path (so ~/outputs works), and if the path exists and is a directory, it walks everything inside - files, symlinks, and subdirectories (via shutil.rmtree) - and removes them. Each deletion is individually wrapped in a try/except, so one locked file won't kill the whole cleanup. If the path doesn't exist or isn't a directory, it does nothing and moves on.
The passthrough is the clever part: it takes an optional any_input of any type and returns it unchanged as any_output. So you can chain it mid-graph - fire cleanup, then pass whatever value you were carrying downstream - without breaking your data flow. It also returns cleanly (the input value) rather than erroring, which is what you want from a utility node.
The inputs that matter
- directory - the path to clear. The only required input. Use an absolute path or
~-based paths (they're expanded); relative paths resolve against wherever ComfyUI runs, so absolute is safer. - any_input (optional) - any data type, passed through untouched.
The output
any_output - whatever you put in any_input, unchanged. If you don't connect anything, it outputs nothing useful.
Installing it
Same pack install as its siblings:
cd ComfyUI/custom_nodes
git clone https://github.com/Aryan185/ComfyUI-ExternalAPI-Helpers.git
cd ComfyUI-ExternalAPI-Helpers
pip install -r requirements.txt
Restart ComfyUI; it appears under Utility/File. No API key, no model, no network - the name is honest: it calls nothing and needs nothing but a path.
Where people get burned
Let's be very clear about the one way this bites: there is no trash can. Deleted is deleted. The node removes files, symlinks, and whole subdirectories without confirmation, and the per-item try/except means a failed deletion is silently skipped, not reported. If you point it at the wrong path - say, your entire ComfyUI folder - that's a bad day. Always double-check the directory field, and if you're nervous, test it on a scratch folder first.
Also, the error-swallowing works both ways: if it can't clear something, you won't know. It's a cleanup tool, not a disk inspector. Use it for the boring, repeatable "start fresh" case and you'll be glad it's there.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| any_inputopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| any_output | * | — |