Nodes/ComfyUI-ZhiHui/🗑️ 智绘_文件夹清理器 (图片流)
ComfyUI Node

🗑️ 智绘_文件夹清理器 (图片流)

The image-passthrough node that (maybe) deletes files — safety switch included

By zhuyungen·Created 8 months ago·Updated 4 months ago· 0
🗑️ 智绘_文件夹清理器 (图片流)
  • image
  • image
◄folder_path./output►
◄file_extensionsjpg, png, txt►
◄enable_deletefalse►

Here's a node that does two very different jobs at once, and the safety switch is the whole story. ZH_FileCleaner (🗑️ 智绘_文件夹清理器 图片流) sits in your image pipeline as a passthrough - IMAGE in, same IMAGE out, never touching your pixels - and on the side deletes files from a folder you specify, matching extensions you choose. By default it deletes nothing: enable_delete is off, and the node just passes your image through while doing the folder housekeeping in "preview" spirit. Flip it on and it becomes a bulk deleter. That default-off design is the one thing that makes it safe to leave in a workflow.

How it works

Mechanically it's two features in one node. The image path is pure passthrough - wire your batch in, it comes out the other side unchanged, so the node can sit anywhere in a graph without altering results. The file path is where the actual work happens: every run, it scans folder_path (default ./output, absolute or relative) for files whose extensions match the comma-separated file_extensions list (default jpg, png, txt), and - only if enable_delete is on - deletes them. It handles the formatting sloppiness for you: spaces and leading dots in the extension list ("jpg, png" and ".jpg, .png" both work), and it skips gracefully if the folder doesn't exist.

This is the classic "clean up after yourself" pattern: the pack's own docs frame it as 图片流专用 - cleanup for image flows, like clearing a temp/output directory between batch runs so the next pass starts fresh.

The inputs that matter

Three inputs, and the one that matters most is the safety switch: enable_delete defaults false, and the node's own docs say it plainly - off means no deletion, just image passthrough; on means files get removed. folder_path is what gets cleaned (make sure it's the folder you think it is), and file_extensions is the filter you point at (delete only temp txt sidecars, not your precious PNGs, by listing just txt). The image input and output are the passthrough pair.

Install

Part of the 智绘灵箱 (ComfyUI-ZhiHui) pack:

cd ComfyUI/custom_nodes
git clone https://github.com/zhuyungen/ComfyUI-ZhiHui.git

Restart ComfyUI (or ComfyUI Manager, "智绘灵箱" / "ComfyUI-ZhiHui"). No special deps - this is plain Python file IO plus tensor passthrough.

Where people get burned

  • Deletion is permanent. No trash can, no recycle bin - os.remove is os.remove. The default-off switch is your friend; the moment you enable it, triple-check folder_path and file_extensions. The "Move (慎用)" warnings on the pack's other file node exist for a reason.
  • It deletes on every run while enabled. Not "delete the folder once" - every execution re-scans and re-deletes matches. If your workflow runs 50 times, it deletes 50 times (idempotently, but still).
  • The passthrough is silent. Nothing tells you whether anything was deleted. If you need confirmation, this isn't the node - check the folder after.
  • Don't point it at your model or input directories. It's built for output/temp folders; it will cheerfully match "png" anywhere you let it.

Genuinely useful as a scheduled-sweep tool - run a batch, sweep the temp folder, never think about it again. Just remember that the entire safety story is one boolean you control, and it defaults to the safe direction for a reason.

Category智绘灵箱/图片

Inputs (4)

NameTypeDefaultDescription
imageIMAGE—
folder_pathSTRING./output—
file_extensionsSTRINGjpg, png, txt—
enable_deleteBOOLEANfalse—

Outputs (1)

NameTypeDescription
imageIMAGE—