Batch Sync Image Caption Files ๐
Give every training image a caption .txt in one shot
- trigger_signal
- log
If you've ever prepped a LoRA dataset, you know the chore: every image needs a matching .txt caption file with the same name, and keeping those two sets in sync by hand is miserable. This node does it in one run. Point it at a folder, and it creates a .txt next to every image that's missing one - optionally pre-filled with a starting caption - and cleans up orphan .txt files that no longer have an image. It's dataset housekeeping, automated.
Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, in the Caption Tools group - the pack's whole reason for existing, per the author, is smoothing out LoRA caption prep.
Why you'd use it
Trainers like kohya, ai-toolkit, and OneTrainer expect image/caption pairs: nazha_001.png and nazha_001.txt, side by side. Managing caption files is one of the most-reported time-sinks in the whole LoRA workflow - people build entire "simple caption editor" tools just to stop doing it by hand. This node kills the setup half of that problem: instead of creating dozens of empty text files one at a time, you sync the whole folder at once.
The caption_content field lets you seed every new caption with the same starting text - typically your trigger word. That maps straight onto how the KB's LoRA-training doc says to caption a character set: use a rare trigger token, then describe what you want to remain variable (clothing, pose, background) and leave the identity features undescribed so they get baked in. Seeding "nazha," into every file gives you that consistent trigger prefix to build on, then you fill in the per-image details.
The inputs and outputs that matter
Required:
directory- the path to your dataset folder. The defaultX://path/to/filesis a dummy placeholder; replace it with a real path.caption_content- the text to put in each newly created caption file. Leave empty to just create blank files, or set your trigger word (e.g.nazha,) to prefill them.
Optional:
trigger_signal(any type) - a wire you can connect to force this node to run at a particular point in your graph's execution order. Useful for sequencing it after an earlier step.
Output is log (STRING) - a report of what it created/removed. Wire it into a show node so you can confirm it did what you expected.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model download - it's a filesystem tool. Nodes appear under the ๐ MieNodes menu.
Common issues
It needs a real, local folder. This operates on a directory on the machine running ComfyUI. On a serverless or cloud ComfyUI (comfy.icu included), there isn't a persistent local dataset folder to point at, so these file-management nodes are really meant for a local install where your training images live on disk. Keep that in mind before you go looking for a folder that isn't there.
Mind the placeholder path. X://path/to/files will fail - it's a stand-in. Paste your actual dataset path.
It creates, it doesn't caption. This node makes and syncs the .txt files and seeds them with caption_content; it does not write descriptions for you. For that, caption the images (JoyCaption, Florence 2, or by hand - the KB's LoRA doc has the current guidance) and use the pack's BatchEditTextFiles to bulk-edit. This node is the "make sure every image has a file" step, not the "write good captions" step.
Read the log before trusting it. Because it can remove orphan .txt files, glance at the log output the first time on a new folder to make sure it only touched what you expected.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | X://path/to/files | โ |
| caption_content | STRING | โ | |
| trigger_signalopt | * | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| log | STRING | โ |