Nodes/ComfyUI_MieNodes/Batch Delete Files ๐Ÿ‘
ComfyUI Node

Batch Delete Files ๐Ÿ‘

Wipe files by extension and prefix, safely-ish

By MieMieeeeeยทCreated about a year agoยทUpdated 21 days agoยท 225
Batch Delete Files ๐Ÿ‘
  • trigger_signal
  • deleted_file_count
  • log
โ—„directoryX://path/to/filesโ–บ
โ—„file_extension.txtโ–บ
โ—„prefixโ–บ

BatchDeleteFiles deletes files in a folder that match an extension, with an optional prefix filter to narrow it further. It's the more structured, less foot-gun-y cousin of the pack's freeform DeleteFiles node - instead of a raw glob path, you give it a directory, an extension, and optionally a prefix, and it clears exactly that set.

It ships in ComfyUI-MieNodes, MieMieeeee's utility pack, in the caption/dataset-tools group.

When you'd use it

The classic move in a LoRA workflow: nuke all the captions and start over. You auto-generated .txt captions, they came out formulaic and wrong (the KB's blunt take is that lazy auto-captioning - old BLIP being the poster child - produces exactly this), and you want a clean slate before re-captioning by hand or with a better tagger. Point BatchDeleteFiles at the folder, set .txt, run, gone. Now the images are caption-free and ready for a fresh pass.

The prefix filter is what makes it safer than a blind glob. Say a previous run wrote a batch of files all named temp_*.png and you only want those gone, not every .png in your dataset. Set file_extension to .png and prefix to temp_, and it deletes only files that match both. Your real training images survive.

How it works

  • directory - the folder.
  • file_extension (default .txt) - which files are eligible for deletion.
  • prefix (optional) - if set, only files whose names start with this string get deleted. Leave it empty to delete every file of that extension in the folder, so know which mode you're in.

Outputs: deleted_file_count (INT, so you can confirm the damage matched your expectation) and log (STRING). There's also an optional trigger_signal (*) for execution ordering - no data, just "run me after that other node."

Wire deleted_file_count into a ShowAnything node and read it before you trust the result.

Installing it

Install the pack. ComfyUI Manager โ†’ search ComfyUI-MieNodes (ComfyUI_MieNodes) โ†’ install โ†’ restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes

then restart. No model download; nodes live under the sheep-emoji ๐Ÿ‘ MieNodes menu.

Common issues

Empty prefix means "everything of this type." The single most likely mistake is leaving prefix blank when you meant to scope the delete. With no prefix and .png, it takes all PNGs in the directory - including your training images. When in doubt, set a prefix, or run the count against a throwaway copy first. There's no recycle bin and no undo.

It acts on the ComfyUI host's disk. Locally that's your machine; on a remote or serverless GPU the X://path/to/files placeholder points nowhere useful, and paths resolve relative to the ComfyUI process. Sort out the real path - GetAbsolutePath helps - before you pull the trigger.

Prefix vs glob. If your selection needs a real wildcard pattern rather than a simple starts-with, BatchDeleteFiles can't express it - that's what the DeleteFiles node's path glob (plus its mock dry-run) is for. Pick the tool that matches how precisely you need to aim.

Category๐Ÿ‘ MieNodes/๐Ÿ‘ Caption Tools

Inputs (4)

NameTypeDefaultDescription
directorySTRINGX://path/to/filesโ€”
file_extensionSTRING.txtโ€”
prefixoptSTRINGโ€”
trigger_signalopt*โ€”

Outputs (2)

NameTypeDescription
deleted_file_countINTโ€”
logSTRINGโ€”