# cms-edit bulk-rtf-replace — Sitewide Rich Text Find-Replace

`bulk-rtf-replace` finds plain text in Rich Text fields across page and article entry trees (including linked components and collections) and replaces it in one pass.

```bash
cms-edit bulk-rtf-replace --find "Old Company Name" --replace-plain "New Company Name" --dry-run
cms-edit bulk-rtf-replace --find "Old Company Name" --replace-plain "New Company Name"
```

**Always dry-run first** and confirm the match count with the user before saving.

All saves create **drafts** only.

---

## How it works

1. Fetches root entries (`page` and `article` by default) from Contentful
2. For each root, loads the full linked entry tree
3. Scans every Rich Text field on every entry in the tree
4. Applies `replace-plain` (same engine as `cms-edit rtf replace`)
5. Saves each modified entry as a draft

---

## Options

| Option | Description |
|---|---|
| `--find <text>` | Plain text to find (required) |
| `--replace-plain <text>` | Plain text replacement (required) |
| `--include <types>` | Root content types (default: `page,article`) |
| `--prefix <slug>` | Only roots whose slug starts with this prefix (e.g. `/blog`) |
| `--limit <n>` | Max root entries total across all `--include` types (default: 500) |
| `--dry-run` | Report matches without saving |

---

## Scoped replace

```bash
# Blog articles only
cms-edit bulk-rtf-replace \
  --find "2024" \
  --replace-plain "2025" \
  --include article \
  --prefix resources/blog \
  --dry-run
```

---

## JSON output

```bash
CMS_EDIT_JSON=1 cms-edit bulk-rtf-replace --find "foo" --replace-plain "bar" --dry-run
```

Dry-run response includes `entriesWithMatches`, `matches`, and per-entry `changes`.

---

## When to use sessions instead

For a **small** number of entries, or when you need `diff` review per page:

```bash
cms-edit open --page-slug /about
cms-edit rtf replace @c1 body --find "…" --replace-plain "…"
cms-edit diff && cms-edit save
```

For **scalar** fields on many entries, prefer `cms-edit batch set`.

---

## Related resources

- Editor task: `task-bulk-find-replace` (confirmation gates)
- `cms-edit search <text>` — discover affected entries before bulk replace