DIGIT Caption Find & Replace
Fix a thousand captions in one go, without the search-and-replace regret
- log
- modified_count
You know that feeling when you've captioned 900 images and then realize every one of them says "man wearing a red jacket" but the character is actually wearing a blue one? DIGIT Caption Find & Replace is the node that fixes it across the whole folder without you writing a script or opening them one by one. It runs a find/replace across every .txt caption file in a folder, and it can also prepend or append text to all of them in the same pass.
It's a boring utility, and that's the point - this is the kind of tool you don't think about until you need it, and then it saves you an hour. Where it shines in the training workflow: cleaning up a bad captioner run, renaming a character token that changed halfway through the project, or force-adding a trigger word and quality tags to a dataset that came from somewhere else.
How it works
Point it at caption_folder, give it find_text and replace_text, and it rewrites every matching .txt file. Leave replace_text empty and it deletes the found text - useful for stripping stray tokens or artifacts. Two details make it safe rather than terrifying:
case_sensitivedefaults to true. That's a deliberate choice: in the captioning worldredandRedare usually different tags, so a case-insensitive replace can mangle more than it fixes.dry_rundefaults to true. The node previews what it would change without writing a single file. Only when you've seen thelogand are happy do you flipdry_runoff and let it commit.
The extras: prefix_text and suffix_text prepend/append to every caption after the find/replace happens, so a single pass can both fix a token and add your standard style tags.
Outputs are log (what changed, file by file) and modified_count (how many files were touched) - the second one is your sanity check that the run did what you expected.
Installing it
It ships in the digit-comfyui pack, so install is the standard drill:
cd ComfyUI/custom_nodes
git clone https://github.com/thedepartmentofexternalservices/comfyui-digit.git
cd comfyui-digit
pip install -r requirements.txt
Or use ComfyUI Manager and search comfyui-digit. One nice thing about this node specifically: unlike most of the DIGIT family it's fully local - no GCP, no API key, no cloud calls. It's pure file I/O on your caption folder, which makes it the cheapest node in the pack and one of the safest to run.
Where people get burned
The classic mistake is going in without dry_run. It defaults to on, but if you've been clicking around it's easy to switch it off and immediately commit a typo'd find string across 800 files. The file-based loop also can't undo itself, so keep the discipline: preview, read the log, then commit. And mind the case_sensitive default - if your find string's casing doesn't match the captions, you'll get modified_count: 0 and wonder why nothing happened. That's the most common "it's broken" report, and it's usually just casing.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| caption_folder | STRING | Path to folder containing .txt caption files. | |
| find_text | STRING | Text to search for in captions. | |
| replace_text | STRING | Replacement text. Leave empty to delete the found text. | |
| case_sensitive | BOOLEAN | true | Case-sensitive matching. |
| dry_run | BOOLEAN | true | Preview changes without writing files. Turn off to apply. |
| prefix_textopt | STRING | Text to prepend to ALL captions (applied after find/replace). Leave empty to skip. | |
| suffix_textopt | STRING | Text to append to ALL captions (applied after find/replace). Leave empty to skip. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| log | STRING | — |
| modified_count | INT | — |