How to Batch Convert and Merge Documents in macOS Terminal Using textutil

Document workflows on macOS frequently involve managing files across multiple competing formats, including Microsoft Word (.docx, .doc), Rich Text Format (.rtf, .rtfd), web documents (.html), and plain text (.txt). When processing hundreds of legacy office files, extracting raw text for machine learning pipelines, or consolidating multi-chapter manuscripts, launching full desktop office suites like Microsoft Word or Apple Pages for manual export is inefficient and unscriptable.

Every Mac includes a native, high-performance command-line document engine named textutil. Powered by Apple’s Cocoa Text System and CoreText frameworks, textutil allows users and system administrators to batch-convert documents between major formats, strip proprietary formatting, concatenate multiple files into unified documents, adjust typography and encodings, and modify document metadata directly from the macOS Terminal without third-party dependencies.

Supported Formats and Core textutil Syntax

The textutil program operates directly on document streams and supports bidirectional conversion between the following major formats:

  • txt: Raw, unformatted plain text.
  • html: Clean HTML markup, ideal for web archiving and publishing.
  • rtf: Standard Rich Text Format.
  • rtfd: Rich Text Format with attachments (a native macOS directory bundle).
  • doc: Legacy Microsoft Word 97–2004 binary format.
  • docx: Modern Office Open XML Word document format.
  • wordml: Microsoft Word 2003 XML format.
  • odt: OpenDocument Text format.

The standard command syntax follows the structure:

textutil -convert FORMAT [options] files...

Converting a Single Document to Another Format

To convert an existing Microsoft Word document into a clean HTML web file, open the Terminal application and specify the target format:

textutil -convert html contract.docx

By default, textutil writes the output to the same directory, replacing the original file’s extension with .html (creating contract.html) while leaving the source file untouched.

To specify an explicit custom output filename or destination folder, use the -output flag:

textutil -convert txt contract.docx -output ~/Documents/contract_plain.txt

Batch Converting Multiple Files Concurrently

The true power of textutil lies in its seamless handling of filesystem wildcards. To convert an entire directory containing dozens of Word documents (.docx) into lightweight plain text files for search indexing, run:

textutil -convert txt *.docx

To convert all RTF notes into standard Word .docx files simultaneously, execute:

textutil -convert docx *.rtf

The operation executes natively against Apple’s CoreText parsing libraries, completing conversions across hundreds of files in seconds with minimal CPU and memory overhead.

Concatenating and Merging Multiple Documents

When compiling research papers, legal briefs, or book chapters written in separate files, textutil provides the -cat (concatenate) option. This option joins multiple source documents together into a single unified file in the specified target format.

To merge three separate Word chapters into a single master document, run:

textutil -cat docx chapter1.docx chapter2.docx chapter3.docx -output Full_Book.docx

You can also merge all files of a specific type in alphabetical order using wildcard expansion:

textutil -cat html *.rtf -output Combined_Report.html

During concatenation, textutil preserves character formatting, paragraph styles, bold/italic markers, and hyperlink structures across document boundaries.

Customising Typography, Font Sizes, and Character Encodings

When converting rich text documents to HTML or plain text, you can enforce specific font faces and fallback character encodings:

  • Font Family Override: Use -font to standardize all text to a specific typeface during conversion:
    textutil -convert rtf -font "Helvetica" notes.txt
  • Font Size: Set a consistent point size across the document:
    textutil -convert docx -font "Times New Roman" -fontsize 12 draft.txt
  • Character Encoding: Enforce UTF-8 encoding when exporting text from legacy documents:
    textutil -convert txt -encoding UTF-8 legacy_doc.rtf

Inspecting and Modifying Document Metadata

Office documents and RTF files often contain embedded metadata properties, such as author names, company affiliations, creation dates, and revision comments. You can inspect and modify these properties using textutil.

To view existing metadata without modifying document contents, use the -info flag:

textutil -info proposal.docx

The command prints document statistics, including word count, character count, page dimensions, author, and creation timestamp.

To update or sanitize document metadata before sharing files externally, pass the appropriate metadata flags:

textutil -convert docx -author "Editorial Team" -company "Digitash Media" -title "Annual Security Review" report.docx

By integrating textutil into macOS shell scripts and automated Automator/Shortcuts workflows, power users can automate document publishing, sanitize sensitive author metadata, and convert high-volume document archives effortlessly.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.