Nodes/ComfyUI_zip/Clean Folders
ComfyUI Node

Clean Folders

The cleanup node for ComfyUI_zip — read the warning before you wire it up

By hmwl·Created 2 years ago·Updated about a year ago· 9
Clean Folders
      input_path
      output_path

      The most important thing to know about this node up front: it permanently deletes a folder, recursively, with no confirmation and no trash bin. So before we get to what it's for, here's the one rule that keeps it safe - only ever give it a bare folder name, never a full path. More on why below, because it's a real Python gotcha, not just caution for caution's sake.

      What it's for

      Clean Folders is the broom that comes with hmwl/ComfyUI_zip's other two nodes, Unzip To Input and Zip Compress. Both of those leave scratch folders behind - Unzip To Input makes a fresh unzip_<timestamp> folder in your input directory on every run, and Zip Compress keeps a temp folder alive in your output directory while it builds a zip. Neither cleans up after itself. If you're running ComfyUI as a long-lived worker - an API deployment, a hosted instance, anything that queues jobs repeatedly without a human tidying the disk between runs - those scratch folders just accumulate. This node exists to delete them at the end of the graph.

      How it works, and the landmine

      It takes two STRING inputs, input_path and output_path, both optional in effect (default is empty, and an empty value is skipped entirely - so you can use just one side if you only need to clean input or only output). Each non-empty path gets joined onto ComfyUI's actual input or output base directory, and if the resulting folder exists, it's wiped with shutil.rmtree - the same call Python uses for "delete this directory tree, no questions asked."

      The landmine is in that join step. Python's path-joining silently discards the base directory if the second piece is an absolute path - that's standard, documented behavior, but it's exactly backwards from what most people expect a "clean up this named folder" field to do. Type a relative name like unzip_1738500000 and it correctly targets <comfyui_input>/unzip_1738500000. Paste in a full path you copied from your file browser - /home/you/something - and the base directory gets thrown away entirely, and that absolute path is what gets recursively deleted. Nothing stops you from pointing this node at your home folder if you're not careful.

      The safe pattern: don't type paths in by hand at all. Wire the folder output from Unzip To Input directly into this node's input_path, and the temp_dir output from Zip Compress into output_path. That guarantees you're always passing exactly the relative folder name the other nodes just created, and ComfyUI's normal execution order makes sure the folder exists before this node tries to touch it.

      Inputs and outputs

      • input_path - folder name (relative to ComfyUI's input directory) to delete. Leave blank to skip.
      • output_path - folder name (relative to ComfyUI's output directory) to delete. Leave blank to skip.

      No outputs. Clean Folders is a pure side-effect node - it's marked as an output node so it can sit at the end of a graph with nothing wired out of it, and that's the whole point: it does its deleting and stops.

      Installing it

      Same as the rest of the pack. ComfyUI Manager: search ComfyUI Zip, install, restart. Or by hand:

      cd ComfyUI/custom_nodes
      git clone https://github.com/hmwl/ComfyUI_zip
      

      No models, no extra dependencies beyond what ComfyUI already has.

      Where people get burned

      The absolute-path issue above is the one that actually matters - everything else about this node is minor by comparison. Beyond that: if a path you gave it doesn't exist, it just logs and moves on rather than erroring, so if you're expecting a folder to disappear and it doesn't, check you passed the exact name (case and all) rather than assuming something failed loudly. And because this pack is tiny - nine stars, one author, no activity in over a year - there's no community thread to search if something about it surprises you; the whole node is short enough to read yourself in the repo before you trust it with rmtree.

      Categorycomfyui_zip

      Inputs (2)

      NameTypeDefaultDescription
      input_pathSTRING
      output_pathSTRING

      Outputs (0)

      No outputs