Every method for searching and replacing text, formatting, and images across hundreds of ODT, ODS, and ODP files — from command-line scripts to dedicated tools.
You have a folder full of LibreOffice or OpenOffice documents and you need to change something across all of them. Maybe your company rebranded and the old name appears in 500 contract templates. Maybe a client's address changed and it's scattered across years of reports. Maybe you migrated servers and every document references a file path that no longer exists.
Whatever the reason, you're staring at the same problem: LibreOffice's built-in Find & Replace only works on the document you currently have open. There is no native feature to search and replace across multiple closed files. This is one of the most requested features in the LibreOffice community, and a decade later, it still doesn't exist in the core application.
So how do you actually do it? This guide walks through every practical method, from manual approaches to scripting to specialized tools, with honest tradeoffs for each.
Why This Is Harder Than It Seems
Before diving into solutions, it helps to understand why batch find and replace in OpenDocument files isn't as straightforward as it would be with plain text files.
ODT, ODS, and ODP files are not text files. They're ZIP archives containing XML documents,
embedded images, style definitions, and metadata. When you open an .odt file in a
text editor, you'll see binary ZIP data — not readable content. The actual document text
lives inside an XML file called content.xml within that archive, interwoven with
XML tags that define formatting, paragraph structure, styles, and more.
This means you can't just use a general-purpose text search tool like grep or
sed on the files directly. You'd be searching through XML markup, which risks
breaking the document structure if you modify it carelessly. A replacement that seems simple
— changing "Acme Corp" to "NewCo Inc" — could corrupt a document if the text happens
to be split across multiple XML elements due to formatting changes mid-word, spell-check
annotations, or change tracking.
Any reliable batch replacement approach needs to understand the OpenDocument format, not just treat the files as raw text.
Method 1: Open Each File and Use the Built-In Find & Replace
The most obvious approach is the manual one: open each document in LibreOffice, press Ctrl+H to open Find & Replace, enter your search and replacement terms, click Replace All, save, close, and move on to the next file.
This works perfectly for two or three files. For thirty files, it's tedious. For three hundred files, it's a full day of mind-numbing work — and you'll inevitably make mistakes, miss files, or forget which documents you've already processed.
If you absolutely must take this route, at least use LibreOffice's ability to open multiple files at once (select them all in the file browser) and then work through the open tabs. But there's a practical ceiling around 20–30 open documents before LibreOffice starts slowing down or running out of memory.
This method only makes sense when you have a handful of files and a single simple text replacement. For anything beyond that, keep reading.
Method 2: The AltSearch Extension
Alternative Find & Replace (AltSearch) is a LibreOffice/OpenOffice extension that significantly enhances the built-in search capabilities. It supports regular expressions, paragraph style searching, and — most relevantly — can execute a saved set of find/replace operations across multiple open documents.
The key limitation is that word "open." AltSearch operates on documents that are currently open in LibreOffice. It doesn't process files on disk. So your workflow becomes: open a batch of documents, run your AltSearch replacement set, save and close them all, then open the next batch. It's better than doing replacements one document at a time, but you're still constrained by how many files LibreOffice can handle simultaneously.
AltSearch is free and genuinely powerful for complex search patterns within individual documents. But for true batch processing across hundreds of files sitting in folders on your drive, it's a workaround rather than a solution.
Method 3: LibreOffice Command Line with Macros
LibreOffice has a command-line interface and a built-in macro system (LibreOffice Basic) that can be combined to automate find and replace operations. The approach involves writing a macro that opens a document, performs the replacements, saves, and closes it, then invoking LibreOffice from the command line to execute that macro against each file.
A basic workflow looks like this: you write a LibreOffice Basic macro that uses the
SearchDescriptor and ReplaceDescriptor API to perform replacements on
the active document. Then you use a shell script or batch file to loop through your files,
calling soffice --headless --macro for each one.
The advantages are that it's free, uses only LibreOffice itself, and can be fully automated. The disadvantages are substantial. Writing and debugging LibreOffice Basic macros is an exercise in patience — the API documentation is sparse, error messages are cryptic, and the macro language feels dated. Running LibreOffice in headless mode can be flaky, with occasional hangs or crashes that require manual intervention. Each file requires launching and tearing down a LibreOffice process (or managing a persistent instance), which is slow. And if you need to handle replacements in headers, footers, or embedded text frames, the macro complexity ramps up significantly.
This is a viable approach for technical users who are comfortable with scripting and only need to do this operation occasionally. For a one-time migration of a few dozen files where you're willing to invest an afternoon in getting the macro right, it can work well.
Method 4: Python Scripting with python-docx or odfpy
Python offers a cleaner scripting experience than LibreOffice Basic for programmatic document
manipulation. The two main libraries for working with OpenDocument files are odfpy
(which reads and writes ODF files natively) and the approach of unzipping the ODT, manipulating
the XML with libraries like lxml, and rezipping.
The odfpy library provides Python classes that map to ODF elements, allowing you to
traverse the document tree and modify text nodes. An alternative approach — and honestly
the more common one you'll find in Stack Overflow answers — is to treat the ODT as a ZIP
file, extract content.xml, perform string or XML-based replacements, and write it
back into the archive.
Python's advantage is a familiar, well-documented language with strong text processing capabilities. Regular expressions are easy to use, error handling is clean, and you can build in logging and dry-run modes.
The disadvantages are meaningful. The naive approach of doing string replacement on
content.xml is dangerous because document text is often split across multiple XML
elements. The word "company" might be stored as
<text:span>comp</text:span><text:span>any</text:span> if
there's a formatting change or spell-check marker in the middle. A simple string search won't
find "company" in that case, and a regex that tries to account for intervening tags can easily
break the XML. Handling this correctly requires walking the XML tree and performing replacements
at the logical text level, which is significantly more complex code.
You also need to handle ODS (spreadsheets) and ODP (presentations) separately since they have different XML structures. And features like searching in headers/footers, replacing images, or preserving formatting during replacements each add another layer of complexity.
For someone with strong Python skills and a specific, well-defined replacement task, scripting is a practical option. For recurring batch operations or anything involving formatting-aware replacements, the effort to build a robust script starts to rival building a dedicated application.
Method 5: The Manual ODT/XML Approach
Since ODT files are ZIP archives, you can manually unzip them, edit the XML content, and rezip
them. On Linux or macOS, this might look like unzipping the ODT, using sed to
perform replacements on content.xml, and zipping everything back up.
This approach has all the risks of the Python XML manipulation method (text split across elements, potential for XML corruption) plus the added fragility of manual ZIP handling. Getting the ZIP structure wrong (wrong compression method, wrong file ordering) can produce files that LibreOffice refuses to open.
This is really only appropriate for emergency situations where you have no other tools available and you fully understand the ODT XML structure. For production use, the risk of document corruption is too high.
Method 6: Sobolsoft OpenOffice Writer Find and Replace
Sobolsoft has offered a dedicated Windows utility for batch find and replace in OpenOffice Writer files for many years. You add files or folders, define your search and replace terms, and process them in bulk.
It addresses the core use case — multiple files, no scripting required. The tool has been around long enough to show up in old forum recommendations across Super User and Reddit threads. However, it's focused specifically on Writer (ODT) documents and text replacement. If you need to process spreadsheets (ODS) or presentations (ODP), replace images, search by formatting, or import replacement lists from a spreadsheet, you'll need to look elsewhere.
Method 7: PowerGREP
PowerGREP is a powerful Windows search-and-replace tool that can work with the contents of ZIP-based file formats like ODT. It uses a built-in converter to access the text content inside OpenDocument files without requiring LibreOffice to be installed.
PowerGREP is overkill if you only work with ODT files — it's designed as a general-purpose tool for searching through many file types. But if you regularly need to search and replace across a mix of file formats (ODT, DOCX, PDF, plain text, source code), it's a versatile choice. It's a paid tool with a significant learning curve due to its extensive feature set.
Method 8: Dedicated Batch Processing Tool (Open Office Find Replace)
This is the problem we built Open Office Find Replace to solve. It's a standalone desktop application designed specifically for batch find and replace operations across LibreOffice and OpenOffice documents.
The workflow is drag-and-drop: add files or entire folders (with recursive subfolder processing), define your replacements, and click process. It supports all three major OpenDocument formats — ODT (Writer), ODS (Calc), and ODP (Impress) — and handles text replacement, formatting-based search (find by font color, bold/italic/underline, highlight color), image find and replace, and targeted search in specific document sections (body text, headers and footers, hyperlinks, notes and comments, spreadsheet formulas).
A few features address pain points that come up constantly in the forum threads about this topic. You can import replacement lists from Excel or CSV files, which is essential when you have dozens or hundreds of substitutions to make (a company rebranding with new names, addresses, phone numbers, URLs, and legal entity names is rarely a single find/replace operation). The "Follow Case" feature preserves the original capitalization pattern when replacing text — so "ACME CORP" gets replaced with "NEWCO INC" while "Acme Corp" becomes "NewCo Inc" in the same pass. And there's a built-in batch PDF conversion feature, so you can process your documents and generate distribution-ready PDFs in a single workflow.
Everything runs locally with no internet connection required and no document data leaving your machine. There's a free trial available, and the full version is $60/year.
Choosing the Right Approach
The right method depends on how often you need to do this and how complex your requirements are.
For a one-time replacement of a single text string across a few files, opening them manually and using Ctrl+H is fine. It's boring, but it's fast and requires no setup.
For a one-time replacement across many files where you're comfortable with scripting, the Python or LibreOffice macro approach can work — budget an afternoon for getting it right and testing thoroughly.
For recurring batch operations, complex replacements (formatting-aware, image replacement, multiple substitutions from a list), or situations where you can't risk document corruption from XML-level manipulation, a dedicated tool will pay for itself in time savings very quickly.
Tips for Safe Batch Replacement
Whichever method you choose, these practices will keep you out of trouble.
Always work on copies first. Before running any batch replacement on your actual files, make a complete copy of the folder and test against that. One bad regex or an unexpected formatting issue can corrupt documents in ways that aren't immediately obvious.
Use the preview or dry-run mode if your tool supports it. Review what will be changed before committing. A replacement that looks correct for one document might have unintended matches in another.
Watch for partial matches. Replacing "art" will also modify "department," "start," and "article." Use whole-word matching when it's available, or be very specific with your search terms. Regular expressions with word boundary anchors help here.
Test with formatting edge cases. If your documents use bold, italic, or colored text, verify that replacements work correctly when the search term spans a formatting change. This is where XML-based approaches commonly break.
Check headers, footers, and text frames. These are separate content areas in OpenDocument files that many replacement methods skip by default. Verify that your approach covers all the document sections where your search term might appear.
Log everything. For large batch operations, keep a record of what was changed in each file. If something goes wrong, you need to know which files were affected and what the original content was.
Summary
Batch find and replace across LibreOffice and OpenOffice documents is a common need with no built-in solution. Your options range from manual file-by-file replacement (simple, slow) through extensions like AltSearch (better, still limited to open files), scripting in Python or LibreOffice Basic (flexible, requires coding and careful XML handling), general-purpose tools like PowerGREP (powerful, broad focus), to dedicated OpenDocument batch processing tools (purpose-built for the task). The complexity of the ODT/ODS/ODP format means that approaches working at the XML level carry real risks of document corruption if they don't handle formatting boundaries correctly.
If you'd like to see batch processing in action, we have a video walkthrough on YouTube demonstrating the full workflow, and you can download the free trial of Open Office Find Replace to test with your own documents.
Need to run find and replace across hundreds of LibreOffice or OpenOffice documents? Contact us or learn more about Open Office Find Replace.