Manipulate text files in various formats.
Syntax
textutil -info [options] file ...
textutil -convert fmt [options] file ...
textutil -cat fmt [options] file ...
textutil -help [options] file ...
Key
-info Display information about the specified files.
-convert fmt Convert the files to format fmt and write each one
back to the file system.
-cat fmt Read the specified files, concatenate them, and write the
result out as a single file in the indicated format.
-help Show usage information and exit.
fmt fmt is one of: txt, html, rtf, rtfd, doc, docx, wordml, odt, or webarchive
Options
-encoding IANA_name | NSStringEncoding
The encoding to be used for plain text or HTML output
(by default, the output encoding will be UTF-8).
-extension ext Specify an extension to be used for output files (by
default, the extension will be determined from the format).
-format fmt Force all input files to be interpreted using the indicated
format (by default, a file’s format will be determined from
its contents).
-font font The font to be used when converting to rich text.
-fontsize size Font size (in points) to be used for converting plain to rich text.
-inputencoding IANA_name | NSStringEncoding
Force all plain text input files to be interpreted using
the specified encoding (by default, a file’s encoding
will be determined from its BOM).
-output path The file name to be used for the first output file.
-stdout Send the first output file to stdout.
-- Specify that all further arguments are file names.
Additional options for HTML and WebArchive files:
-noload Do not load subsidiary resources.
-nostore Do not write out subsidiary resources.
-baseurl url Specify a base URL to be used for relative URLs.
-timeout t The time in seconds to wait for resources to load.
-textsizemultiplier x A numeric factor by which to multiply font sizes.
-excludedelements (tag1, tag2, ...)
Specify which HTML elements should not be used in generated
HTML (the list should be a single argument, and so will
usually need to be quoted in a shell context).
-prefixspaces n The number of spaces by which to indent nested
elements in generated HTML (default is 2).
Additional options for the output file metadata:
-strip Do not copy metadata from input files to output files.
-title val The title metadata attribute for output files.
-author val The author metadata attribute for output files.
-subject val The subject metadata attribute for output files.
-keywords (val1, val2, ...)
The keywords metadata attribute for output files
(the list should be a single argument, and so will usually
need to be quoted in a shell context).
-comment val The comment metadata attribute for output files.
-editor val The editor metadata attribute for output files.
-company val The company metadata attribute for output files.
-creationtime yyyy-mm-ddThh:mm:ssZ
The creation time metadata attribute for output files.
-modificationtime yyyy-mm-ddThh:mm:ssZ
The modification time metadata attribute for output files.
Textutil first appeared in OS X 10.4
The textutil command exits 0 on success, and 1 on failure.
Some options may require a connection to the window server.
Display information about foo.rtf:
$ textutil -info foo.rtf
Convert foo.rtf into foo.html:
$ textutil -convert html foo.rtf
Convert a Word document windevcluster.docx into HTML - windevcluster.html:
$ textutil -convert html windevcluster.docx
Convert foo.txt into foo.rtf, using Times 10 for the font:
$ textutil -convert rtf -font Times -fontsize 10 foo.txt
Load all RTF files in the current directory, concatenate their contents, and write the result out as index.html with the HTML title set to Several Files":
$ textutil -cat html -title "Several Files" -output index.html *.rtf
Create a .txt file from each .docx Word document file in the directory:
$ textutil -convert txt *.docx
“A lot of people are afraid to say what they want, that’s why a lot of people don’t get what they want” ~ Madonna
Local man page: textutil - Command line help page on your local machine.
GetFileInfo - Get attributes of HFS+ files.
pr - Convert text files for printing.
say - Convert text to audible speech.
setfile - Set attributes of HFS+ files.
sips - Scriptable image processing system.