How to find and replace text across a folder of documents without breaking the formatting
Leave feedback
On this page
When a supplier renames itself, every contract, rate card and slide deck that names it needs the same edit. Run the GroupDocs.Editor MCP server locally and ask your agent: it calls replace_text once per file, keeps the formatting, and tells you how many places changed in each — including the files where nothing matched:
dnx GroupDocs.Editor.Mcp --yes
with GROUPDOCS_MCP_STORAGE_PATH pointing at your documents folder — or the Docker image, ghcr.io/groupdocs-editor/editor-net-mcp. Per-client config: Register in AI clients.
In every document in the contracts folder, plus budget.xlsx and review.pptx, replace ACME Corp with Globex Ltd as a whole word. Tell me how many changes per file.
Note
The commands and config snippets on this page are for the .NET build of the server — the only platform available today. Installation and client setup: MCP server for .NET. Other platforms will expose the same tools with their own launch command; everything else on this page applies unchanged.
Prerequisites
The server registered in your AI client, the documents inside the storage folder — quick start.
An agent that can list the folder (its own file tools), or the file names in the prompt.
The calls
for each file the agent finds in contracts/ and the shared folder:
replace_text {"find":"ACME Corp","replace":"Globex Ltd","wholeWord":true}
msa-northwind.docx -> Replaced 6 -> msa-northwind_edited.docx
nda-northwind.docx -> Replaced 1 -> nda-northwind_edited.docx
welcome-letter.docx -> no matches -> nothing written
budget.xlsx (sheet 1)-> Replaced 1 -> budget_edited.xlsx
review.pptx (slide 1)-> Replaced 1 -> review_edited.pptx
the agent reports: 9 changes in 4 files, 1 file without the name
What the agent sees
Captured from server 26.10.0 against a synthetic set: an agreement and an NDA in contracts/, a welcome letter that never mentions the supplier, a three-worksheet budget and a three-slide deck. The server prints the full path inside your storage folder; it is shortened to …/ here, and the evaluation line every response starts with is trimmed unless shown.
-> replace_text {"file":{"filePath":"contracts/msa-northwind.docx"},
"find":"ACME Corp","replace":"Globex Ltd","wholeWord":true}
<- Replaced 6 occurrence(s) of 'ACME Corp' in 'msa-northwind.docx'
Saved to: …/msa-northwind_edited.docx
-> replace_text {"file":{"filePath":"contracts/welcome-letter.docx"}, ...}
<- Text replacement found no matches for 'ACME Corp' in
'welcome-letter.docx'. No file was written.
-> replace_text {"file":{"filePath":"budget.xlsx"}, ..., "worksheet":1}
<- Replaced 1 occurrence(s) of 'ACME Corp' in worksheet 1 of 3 of
'budget.xlsx'
Saved to: …/budget_edited.xlsx
-> replace_text {"file":{"filePath":"review.pptx"}, ..., "slide":3}
<- Text replacement failed for 'review.pptx' (find='ACME Corp'): Evaluation
mode edits only the first 2 slides of a presentation; slide 3 is beyond
them. Set GROUPDOCS_LICENSE_PATH, or the metered keys, to edit every part.
Four things to notice:
The count is per file, and a file without the name says so and writes nothing — the agent can report “the welcome letter does not mention ACME” instead of a vague “done”.
Workbooks and decks are edited one part per call. The budget names the supplier on worksheet 1; the deck on slides 1 and 3. Ask the agent to check each part (get_document_info gives the count).
Evaluation mode stops at part 2, with an error that says so. Licensed, slide 3 is edited like the others.
Edited copies land in the output folder’s root — msa-northwind_edited.docx, not contracts/msa-northwind_edited.docx. Use outputName to keep a naming scheme.
Can it edit a whole folder in one call? No — one document per call, which is what makes the per-file count possible. The agent loops.
Does it edit headers, footers and tables? Tables, yes (two of the agreement’s six occurrences were in the fee table). Check headers and footers in the result for your documents.
Can it work on a code repository’s documents? Yes — point the storage folder at the repository and ask, for example, to bump v2.3 to v2.4 in the release-notes DOCX and the spec XLSX. Add the edited copies to .gitignore or rename them over the originals deliberately.
Add to your CLAUDE.md or AGENTS.md
Agents follow project instructions about when to use a tool. Paste this into the instruction file your agent reads (CLAUDE.md, AGENTS.md, .github/copilot-instructions.md, .cursorrules):
For wording changes across documents in ./documents, call groupdocs-editor
replace_text once per file and per worksheet/slide; use wholeWord for names.
Report a count per file and list files with no match. Never re-type a document.
Honest limits
Evaluation mode: every edited document starts with an evaluation banner, a saved workbook gains an Evaluation Warning worksheet, and only worksheets and slides 1–2 can be edited (a PDF extraction holds two pages). Licensing.
One formatting run:replace_text does not see a phrase whose words are formatted differently; use the HTML round-trip for those.
No tracked changes: the edited copy carries the new text, not a redline.
PDF editing is a conversion: text and structure come across; exact page layout does not.