Convert Font Family and Text Size of a Document from the Command Line

Jul 8, 2011 - Leave a Comment

Convert font and text size of a document

The powerful textutil command for Mac offers an amazing capability to convert a text documents font family and text size, transforming the document with ease and precision right from the command line of Mac OS.


In addition to being able to convert TXT files to RTF or other filetypes, you can go beyond simply changing file type and also use textutil to convert the font family and font size of a document from the command line, thereby manipulating the document from the Terminal without having to open it in another text editor or GUI app. For example, you could change an entire RTF file to be font size 30 with font family Comic Sans or font family Courier. Or if a formatting is undesirable, you could make it easier to read by shrinking the font size and using a friendlier font face like Palantino. The options are up to you.

How to Convert Font Face and Font Text Size in Documents via Command Line on Mac

Launch the Terminal application to get started. Be sure you have a document you want to try this out on, it can be just about any text file as long as it has text in it.

The syntax for doing the font family and font text size conversion is as follows:

textutil -convert filetype -font fontfamily -fontsize ## filename.txt

For example, to convert file.txt to an RTF document with size 24 Helvetica font, we would use:

textutil -convert rtf -font Helvetica -fontsize 24 file.txt

The conversion is practically instantaneous. Because this is scriptable from the command line, it is potentially more useful than just opening a document in TextEdit and going about this through the GUI, at least for some Mac users.

.

Related articles:

Posted by: William Pearson in Command Line, Tips & Tricks

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site