Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Batch Convert Text Files on Mac: 4 Built-In Ways

· 5 min read · Home Tech

In this article
  1. Why Batch Convert Text Files?
  2. Method 1: Automator (Drag-and-Drop, No Coding)
  3. Method 2: Terminal (Powerful and Flexible)
  4. Method 3: TextEdit (For Small Batches)
  5. Method 4: Third-Party Apps
  6. How to Choose the Right Method
  7. Common Problems and Fixes
  8. Frequently Asked Questions

To batch convert text files on a Mac, you can use the built-in TextEdit app, the Automator workflow tool, the Terminal command line, or a dedicated third-party converter. The fastest no-install method is Automator, which lets you drag and drop multiple files onto a saved workflow to change their encoding or format in one go.

Why Batch Convert Text Files?

Text files come in many encodings (UTF-8, UTF-16, Windows-1252, etc.) and line-ending styles (LF, CRLF, CR). A file created on Windows often opens with garbled characters or shows weird symbols on a Mac because of encoding mismatches. Batch conversion lets you fix dozens or hundreds of files at once, saving you from opening and re-saving each one manually. This is especially useful for developers, writers, and data analysts who receive files from multiple sources.

Method 1: Automator (Drag-and-Drop, No Coding)

Automator is a free app that comes with every Mac. It can create a workflow that converts text files in bulk. Here’s how to set it up:

  1. Open Automator (in /Applications/Utilities).
  2. Choose New Document and select Workflow.
  3. In the left library, search for “Change Type of Documents” and drag it into the workflow area.
  4. Set “Change type of documents to” to Text Encoding (or “Plain Text” if you want to strip formatting).
  5. Add a “Set Value of Variable” action to capture the converted files.
  6. Add a “Move Finder Items” action to save them to a folder you choose.
  7. Save the workflow (File > Save) and drag any number of text files onto its icon in Finder.

This method preserves the original files and creates new ones in your chosen destination. It’s ideal for people who prefer a visual interface over typing commands.

Method 2: Terminal (Powerful and Flexible)

If you’re comfortable with the command line, Terminal gives you precise control. The iconv command converts character encodings, and dos2unix/unix2dos (installable via Homebrew) handle line endings. Here’s a simple loop to convert all .txt files in a folder from Windows-1252 to UTF-8:

for f in *.txt; do iconv -f WINDOWS-1252 -t UTF-8 "$f" > "converted_$f"; done

This creates new files with the prefix “converted_”. To overwrite the originals, add mv after the conversion. For line-ending conversion, use sed 's/\r$//' file.txt > newfile.txt to strip carriage returns. Terminal is the fastest method for large batches but requires caution—always test on a copy first.

Method 3: TextEdit (For Small Batches)

TextEdit can open multiple files at once and re-save them, but it’s not truly automated. Open all the files (File > Open, select multiple), then use File > Save As for each one, choosing the desired encoding from the “Plain Text Encoding” dropdown. This works for a handful of files but becomes tedious for more than ten. It’s a good fallback if you don’t want to install anything or learn commands.

Method 4: Third-Party Apps

Several free and paid apps specialize in batch text conversion. Popular options include TextWrangler (now BBEdit’s free version), Sublime Text (with the “ConvertToUTF8” plugin), and Batch Text Converter from the Mac App Store. These apps often provide a graphical interface where you can set source and target encodings, preview changes, and process thousands of files. They’re useful if you need advanced features like filename pattern matching or recursive folder scanning.

How to Choose the Right Method

Your choice depends on the number of files and your technical comfort:

  • 1–5 files: TextEdit saves each one manually.
  • 5–100 files: Automator workflow is quick and safe.
  • 100+ files or regular use: Terminal script or a dedicated app saves time.
  • Need to change encoding only: iconv in Terminal is the most reliable.
  • Need to change line endings only: dos2unix/unix2dos are purpose-built.

If you’re unsure what encoding a file uses, open it in TextEdit and look at the “Plain Text Encoding” field in the Open dialog—it shows the detected encoding. You can also use the file command in Terminal to see the encoding.

Common Problems and Fixes

Batch conversion often hits a few snags:

  • Garbled characters after conversion: The source encoding was wrong. Use file to detect the actual encoding before converting.
  • Files are overwritten accidentally: Always write to a new folder or add a prefix. Automator’s “Move Finder Items” lets you choose a destination.
  • Line endings don’t change: Some apps only change encoding, not line endings. Use separate tools for each.
  • Automator workflow fails on some files: It may not handle binary or non-text files. Filter by extension (.txt, .csv, .log) before adding the action.

Another misconception is that changing the file extension (e.g., .txt to .rtf) converts the format. It doesn’t—the content remains plain text. You need to change the actual encoding or file type.

Frequently Asked Questions

Can I batch convert text files without installing anything?

Yes. Automator and Terminal are both built into macOS. Automator requires no scripting knowledge, while Terminal uses commands that are already available. TextEdit also works but only for a few files at a time.

What is the difference between UTF-8 and UTF-16?

UTF-8 uses 1 to 4 bytes per character and is backward-compatible with ASCII, making it the most common encoding for web and cross-platform files. UTF-16 uses 2 or 4 bytes per character and is often used by Windows applications like Notepad for files with many non-Latin characters. For most Mac use, UTF-8 is the safer choice.

Will batch conversion break my files?

If you convert to the wrong encoding, characters may become garbled or lost. Always work on copies or a backup. Using a tool like iconv with a destination file (not overwriting) lets you verify the result before replacing the original.

How do I convert line endings from Windows (CRLF) to Mac (LF)?

Use the dos2unix command (install via Homebrew) or a simple Perl one-liner: perl -pi -e 's/\r\n/\n/g' file.txt. This replaces carriage returns with line feeds, making files display correctly in Mac editors.

Can I convert multiple files with different encodings in one batch?

Yes, but you need to detect each file’s encoding first. A Terminal script can loop through files, run file to detect encoding, and then apply the appropriate iconv command. Automator doesn’t handle this automatically; you’d need to sort files by encoding first.

Is there a way to convert files in the Finder without opening an app?

Yes. Save an Automator workflow as a Quick Action (in the Automator save dialog, choose “Quick Action” as the workflow type). Then select files in Finder, right-click, and choose your workflow from the Quick Actions menu. This integrates batch conversion into the context menu.