ComfyUI Node

clear file

Delete a temp file inline without breaking your graph

By heshengtao·Created 2 years ago·Updated 6 days ago· 2,321
clear file
  • any
  • any
path
is_enabletrue

Agent workflows that touch Discord, DingTalk, or a knowledge base tend to accumulate temp files - a screenshot saved before sending, an audio clip generated for a bot, a document uploaded for embedding. Left alone, those pile up on disk. clear file is the pack's cleanup utility: delete a specific file, and keep your workflow's data flowing through the same wire like nothing happened.

How it works

The trick is the pass-through design. Most "delete a file" logic would be a dead-end node - you'd call it, and then have nowhere for your graph to continue from. This node instead takes an any-typed input, deletes whatever's at path as a side effect, and then outputs that same any value unchanged. That means you can splice it directly into the middle of an existing wire - right after you're done using a temp file - without restructuring anything downstream.

The inputs and outputs that matter

  • any - whatever value you want to pass through untouched; this is what makes the node insertable mid-graph rather than a dead end.
  • path - the file to delete when this node runs. Get this wrong and you either delete nothing (harmless) or delete something you didn't mean to (not harmless) - there's no confirmation step.
  • is_enable - toggle the deletion off without removing the node from the graph, useful while you're still debugging a workflow and don't want files disappearing yet.
  • One output: any - the same value that came in, so downstream nodes never notice this step happened.

How to install it

  • ComfyUI Manager - search "comfyui_LLM_party", install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/heshengtao/comfyui_LLM_party, then restart.

Then pip install -r requirements.txt from inside the comfyui_LLM_party folder, in your ComfyUI Python environment (python_embeded\python.exe -m pip install -r requirements.txt on portable Windows). No extra dependency for this node - it's a filesystem call, nothing more.

Common issues & troubleshooting

Something important got deleted. path is a free-text field with no confirmation or undo - a typo, a hardcoded path left over from testing, or a variable that resolved differently than you expected will delete whatever's actually there, not what you meant. Double-check path is dynamically wired to the specific temp file you just used (an img_path or audio_path from an upstream discord_send, say), not a static path you copy-pasted once and forgot about.

File "in use" errors. If the file was just written by another node in the same run and something else still has a handle open on it (common with audio files mid-write), deletion can fail. Make sure this node runs strictly after whatever produced and consumed the file, not in parallel with it.

Nothing gets deleted and you don't notice. Check is_enable - it's easy to leave this toggled off from a debugging session and wonder later why temp files are piling up again.

The pack won't load at all. Separate from this node, comfyui_LLM_party has a real, current install issue where nodes fail to import after a Manager install - usually a CUDA/PyTorch mismatch with no clear compatibility list. Check that first if clear_file isn't showing up in your node browser.

Category大模型派对(llm_party)/工作流(workflow)

Inputs (3)

NameTypeDefaultDescription
any*
pathSTRING
is_enableBOOLEANtrue

Outputs (1)

NameTypeDescription
any*