Nodes/honda-nodes/πŸ“‚ Delete Directory
ComfyUI Node

πŸ“‚ Delete Directory

Recursive, silent, and it will not ask twice

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
πŸ“‚ Delete Directory
    • Deleted Path
    β—„pathβ–Ί

    Read this before you wire it

    Delete Directory removes a folder and everything inside it, on whatever path its input string happens to contain, at whatever moment the node executes. There's no confirmation dialogue, no dry run, no trash folder. The implementation is shutil.rmtree(path, ignore_errors=True), which means it also swallows failures - a permission error or a locked file does not raise, it just leaves something behind and reports success.

    That combination is worth saying plainly: this is the most dangerous node in a pack full of harmless helpers, and it's dangerous for a boring reason. The path is a string, strings come from other nodes, and other nodes come from lists you built three hours ago. A typo in a πŸ“‹ Array Get Item index, a πŸ“‹ Array Slice off by one, an empty string that got through a filter - and the thing being pointed at isn't the run folder you meant.

    Practical rule: put a hardcoded path in this node (or a πŸ“‚ Directory β†’ πŸ“‚ Path Join chain you've actually looked at), never a list element, unless you've just tested the list element with a print node.

    How it works

    Path is stripped, and if non-empty, rmtree runs with ignore_errors=True. The stripped path is returned on the output so it can be logged or chained.

    Two details follow from that. Empty string means nothing happens - no error, no deletion. And ignore_errors=True means "the folder may still exist afterwards and the node will not tell you". If you need to know whether it worked, follow with πŸ“‚ List Files on the same path and look at the output, or just check the disk.

    The other thing to internalise is execution timing. This is a normal (non-output) node, so it only runs when something downstream needs its Deleted Path. That's cold comfort if you were hoping it would not run: the moment you wire the output into a log or a preview, you've made it mandatory, and every queue of the workflow deletes that folder again.

    Inputs and output

    Path - a STRING, absolute, typed or wired. Typed is safer here for the reason above. The pack's πŸ“‚ Directory and πŸ“‚ Path Join nodes exist precisely so paths can be assembled and normalised before something destructive consumes them.

    One output: Deleted Path (STRING), which exists mostly so you can print it. Wire it to πŸ› οΈ Print to Console while you're setting the workflow up - the console line is your only audit trail, and it's a lot better than the alternative of wondering which folder went missing.

    The sane cleanup pattern

    Unattended runs fill a disk. The usual fix is "keep the last N runs", and you can build it: πŸ“‚ List Files over the parent β†’ πŸ“‹ Array Slice to take everything past the newest few β†’ walk the list with πŸ“‹ Array For Each β†’ its Item into Delete Directory. That's a genuinely good pipeline and it's also four nodes of rope. Test it with a print instead of a delete first, run it on a scratch directory second, and only then point it at ComfyUI/output.

    For the common case, though, don't automate at all. Manual cleanup is cheaper than one accidental rmtree.

    Install

    Manager: Extensions β†’ Node Pack β†’ search "Honda Nodes" β†’ Install β†’ restart, or:

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    cd honda-nodes
    python install.py     # ComfyUI's python; portable Windows: ..\..\..\python_embeded\python.exe install.py
    

    Pure Python, no binaries - but the pack as a whole wants them for the JSON and metadata nodes, and it wants ComfyUI 0.38.0+ because it's V3-schema only. Also on Windows: the install.py path in the README assumes the portable build's python_embeded; if you run ComfyUI from a venv, use your venv's python.

    Common issues

    Nothing was deleted and there was no error. ignore_errors=True. Permissions, a file open in another app, or a path that doesn't exist - all silent. Check the path in a console print and check the folder on disk.

    It deleted the wrong thing. Almost always a wired path whose upstream changed. Put the path back under manual control and rebuild the pipeline more slowly.

    It deletes on every queue. Yes - once its output is consumed, it's part of every job. If you want a one-shot, unplug the output.

    Deleting a directory that's also a model folder or an output root. ComfyUI will happily let you. The node does not know what a "safe" path is, and neither does the pack. That judgement is yours, and it's why the tooltip says absolute path and the community advice is the same everywhere: never point a recursive delete at a path you didn't read out loud first.

    Category⚑️ Honda Nodes/πŸ“‚ File System

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRINGAbsolute path to the directory to delete.

    Outputs (1)

    NameTypeDescription
    Deleted PathSTRINGβ€”