Skip to content

textutil MacOS command

The MacOS textutil command allows users to perform various operations on text files, such as converting between different text formats, modifying text content, and analyzing text files. This powerful command-line tool provides options for manipulating text files in bulk, making it a versatile tool for managing text content. Users can leverage textutil to streamline workflows, automate text-related tasks, and ensure consistency across text documents. With its wide range of features and functionalities, textutil is a valuable tool for anyone working with text files on MacOS.

textutil Syntax:

Terminal window
textutil [option] [parameter]

textutil Options:

OptionDescription
-convert formatConvert input file to specified format
-infoDisplay information about the input file
-cat formatConcatenate input files into specified format
-stdinRead from standard input
-stdoutWrite to standard output
-font fontnameSet the font used when converting to RTF or Word format
-inputencoding encodingSpecify the encoding of the input file
-outputencoding encodingSpecify the encoding of the output file
-showfontsDisplay available font names
-excludedproprietaryExclude proprietary RTF extensions when converting to RTF format
-extension extensionSpecify file extension when using -output and input files have no extension
-noloadDo not load the main window when launched
-pagewebarchiveConvert to a Web Archive
-htmlConvert to HTML format
-intleditingSet internal unicode bit to allow editing of unicode characters in Word format output
-font fontnameSet the font used when converting to RTF or Word format
-fontsize sizeSet the font size when converting to RTF or Word format

Parameters:

ParameterDescription
inputfile(s)The file(s) to be processed by textutil
outputfileThe output file for the result of the textutil command
directoryThe directory where the output file will be saved
formatThe format to convert the input file(s) to, such as rtf, html, doc, docx, txt, etc.
fontnameThe name of the font to use when converting to RTF or Word format
encodingThe encoding to use for the input or output file
extensionThe file extension to use when input files have no extension

textutil Command Usage Examples:

Convert a TXT file to RTF

Terminal window
textutil -convert rtf example.txt

Converts the text file “example.txt” to Rich Text Format (RTF).

Convert a DOCX file to TXT

Terminal window
textutil -convert txt example.docx

Converts the Word document “example.docx” to plain text format (TXT).

Display Word Count of a Text File

Terminal window
textutil -info example.txt | grep "Words"

Displays the word count of the text file “example.txt”.

Convert a DOC file to HTML

Terminal window
textutil -convert html example.doc

Converts the Word document “example.doc” to HTML format.

Convert a HTML file to DOCX

Terminal window
textutil -convert docx example.html

Converts the HTML file “example.html” to Word document (DOCX) format.

How do I use textutil in MacOS?

To use the textutil command in bash, execute the following command:

Terminal window
textutil --convert txt document.rtf

What is the purpose of the textutil command in MacOS?

The textutil command in MacOS is used for various text-related operations, such as converting between different text formats, adjusting text formatting, and interacting with text files in the terminal.

How can I convert a text file to a different format using textutil?

To convert a text file to a different format using textutil, you can use the following command:

Terminal window
textutil -convert <format> <input_file>

Can textutil be used to convert Rich Text Format (RTF) files?

Yes, textutil can be used to convert Rich Text Format (RTF) files to other formats or vice versa. One example of converting an RTF file to a PDF file is shown below:

Terminal window
textutil -convert pdf document.rtf

How can I view the available options and usage information for textutil?

To view the available options and usage information for the textutil command, you can use the following command:

Terminal window
textutil --help

Is it possible to adjust the formatting of a text document using textutil?

Yes, you can adjust the formatting of a text document using textutil by specifying options like font, size, and spacing. An example of adjusting the font size of a text file is shown below:

Terminal window
textutil -font Times 12 document.txt

How do I strip text formatting from a document using textutil?

To strip text formatting from a document using textutil, you can use the following command:

Terminal window
textutil -convert txt document.rtf

Can textutil handle batch processing of multiple text files?

Yes, textutil can handle batch processing of multiple text files by specifying multiple input files or using wildcards in the command. An example of converting multiple RTF files to TXT files is shown below:

Terminal window
textutil -convert txt *.rtf

Applications of the textutil command

  • Convert text
  • Convert RTF
  • Convert RTFD
  • Convert Word
  • Convert WordML
  • Convert HTML
  • Convert ODT
  • Convert webarchive
  • Convert XML
  • Convert MHT
  • Convert plain text
  • Combine text files
  • Merge RTF files
  • Merge RTFD files
  • Merge Word documents
  • Merge WordML documents
  • Merge HTML files
  • Merge ODT files
  • Generate a Table of Contents
  • Format a document for printing
  • Check spelling and grammar.