Convert batch of Word files to PDFs in Mac OS X

Say I have several Word files in a folder. Is there a way to generate a batch of PDFs from these files?

asked Sep 21, 2011 at 12:57 Joe Mornin Joe Mornin 1,667 4 4 gold badges 18 18 silver badges 24 24 bronze badges

10 Answers 10

Provided you have MS Word (or any other app that can open MS Word files) installed, you can use Automator. Here is a step by step guide on how to set it up for your needs: http://aseriesoftubes.com/articles/how-to-batch-convert-doc-files-to-pdf-format-using-mac-osx-automator/

Brief overview of the whole process:

  1. Open Automator
  2. Create a new workflow
  3. From the library panel on the left, select Files & Folders then double-click Get Specified Finder Items
  4. Add the all the files to convert
  5. From the library panel, now select Documents , then double click Convert Format of Word Documents
  6. From the dropdown menu, select Portable Document Format (PDF)
  7. Finally, click the Run button, and it will convert all the files and save them in the same folder where the original Word files are.
answered Sep 21, 2011 at 14:35 1,647 12 12 silver badges 12 12 bronze badges

I don't see this option ( Convert Format of Word Documents ) in Automator in OS X El Capitan. Did it get removed?

Commented Jul 18, 2016 at 14:30 Office 2016 has dropped Automator support. Could this be the reason you can't see that option? Commented Jul 18, 2016 at 15:10 I don't see it on Mojave Either. I want to convert mhtml to pdf! Commented Apr 21, 2020 at 23:12

You can use the docx2pdf command line utility to batch convert docx to pdf on macOS (or windows). It uses Microsoft Word's APIs to directly convert to PDF creating a perfect copy. It uses JXA (Javscript for Automation, basically AppleScript in JS) in macOS and win32com in Windows.

pip install docx2pdf docx2pdf myfolder/ 

Disclaimer: I wrote this tool after struggling to find a cross-platform solution for batch converting docx to pdf with zero formatting issues since it directly uses Microsoft Word. https://github.com/AlJohri/docx2pdf

answered Dec 24, 2019 at 0:01 676 7 7 silver badges 5 5 bronze badges

Just tried this today in macOS Catalina 10.15.5. There were some pop-up messages in Word that needed to be clicked through in order to make it work, but once I did that, it worked like a charm.

Commented Jun 28, 2020 at 2:14 worked well once you click those permissions popups Commented Mar 6, 2021 at 11:02 The popups make this tool barely usable for large numbers of documents. Commented Jan 12, 2023 at 19:35

The popups only happened once per folder for me. It did take a few clicks to deal with a recovery file (file name starts with ~$ ) that was in the folder. I recommend removing any of those before you start converting.

Commented May 26, 2023 at 11:53

One option using the command line would be to use pandoc (which requires LaTeX for PDF generation).

  1. Install pandoc and LaTeX. Because LaTeX is so big, I installed BasicTeX as recommended in the pandoc docs. With Homebrew and Homebrew Cask: brew install pandoc && brew install --cask basictex
  2. Make sure the Word files are in .docx format. If they are in .doc format, you can convert them with OS X's built-in textutil : textutil -convert docx *.doc
  3. On El Capitan you have to add the texbin utilities to your PATH: export PATH=/Library/TeX/texbin:"$PATH"
  4. Convert: pandoc -o myfile.pdf myfile.docx

Because your question was regarding batch converting multiple files, you could easily put this into a loop:

#! /bin/bash for file in *.doc; do textutil -convert docx "$file" # Account for the new `x` in `docx` pandoc -o "$pdf" "$x" done 
1,191 9 9 silver badges 13 13 bronze badges answered Jul 18, 2016 at 16:10 315 3 3 silver badges 10 10 bronze badges

This failed on a document containing .wmf images. In my case that was a document with math equations. I also tried it on a document of Matlab code. In that case it produced a PDF but the formatting was wrong.

Commented May 26, 2023 at 11:31

Seems like the Automator solution doesn't work anymore.

So there is a simple one.

Install the CUPS-PDF module for OS X. This is a virtual PDF printer that looks like a "real" printer to the system, but creates a PDF file when you send a document to it.

If you make it as your default printer, then you just have to mass select all your files and do "Command" + "P" (shortcut). Mac OSX will open all files, send them to print in pdf, then close them = Simple and it works (on my Mac OS X 10.8.2 Montain Lion)

"After you have installed the Virtual Printer using CUPS-PDF, there is a simpler and more powerful way to batch convert any set of documents to PDF files.

Use Printer Setup Utility to create a Desktop Printer icon for the Virtual Printer. After it is created, I put it in my Dock for easy access.

In the Finder, drag your file icons to the Virtual Printer icon. For Microsoft Word documents, Microsoft Word will be opened and instructed to print each document to that printer.

Unlike the Microsoft Word Macro method, you can do this for any other document created by any other program. As necessary, the Finder will open the appropriate application and tell it to print to the Virtual Printer.

There are two mild limitations to this general method.

(1) The files you drag to the printer icon need to be ones that the Mac knows what to do with (i.e. you can double-click to open it in some program on your Mac).

(2) The document's default "Open With" application needs to support the AppleScript command for Print. All well-behaved MacOS X programs do this. NeoOffice for example doesn't, and thus batch converting native NeoOffice documents does not work for this printer icon method."

answered Oct 25, 2012 at 14:29 Pikatchu46X Pikatchu46X 31 1 1 bronze badge

This is a really simple solution and works great on newer macOS/Word versions! Since CUPS-PDF seems to be abandoned, I used github.com/rodyager/RWTS-PDFwriter instead.

Commented Mar 27 at 14:38

Unfortunately Office 2016 and later (including Office 365) no longer supports Automator. You can work around this using AppleScript.

This solution uses:

The AppleScript script

The purpose of the script is, for the filename passed in, to open the file in word, and then save the file with a .pdf extension instead of .doc or .docx.

on run repeat with aFile in input repeat 1 times -- # fake loop -- Create the output filename tell application "System Events" set inputFile to disk item (aFile as text) tell (info for input) to set Nm to name if (text -5 thru -1 of Nm) is ".docx" then set outputFileName to ((text 1 thru -6 of Nm) & ".pdf") else if (text -4 thru -1 of Nm) is ".doc" then -- .doc set outputFileName to ((text 1 thru -5 of Nm) & ".pdf") else -- If this isn't a word document, continue to the next file. exit repeat end if end tell -- Open word, save as PDF in default path tell application id "com.microsoft.Word" activate open aFile tell active document save as it file name outputFileName file format format PDF close saving no end tell set defaultPath to get default file path file path type documents path end tell -- Move to output location tell application "System Events" set outputPath to (container of inputFile) set outputFile to disk item outputFileName of folder defaultPath move outputFile to outputPath end tell end repeat end repeat return input end run 

The Automator Application

  1. Open automator
  2. File / New then select Application
  3. From the actions Library in the left hand nav, select "Run AppleScript" and drag it into the window on the righ
  4. Copy and paste the code above into the Run AppleScript window.
  5. Save the application as "WordToPdf.app" on the Desktop

Calling it from the command line

  1. Open Terminal
  2. Change Directory to the one you wish to run the script in. Note that it is recursive and will process all files in all subdirectories
  3. Run the following code:
 find . -type f \( -iname \*.doc -o -iname \*.docx \) -print0 | while read -d $'\0' file do automator -i "$file" ~/Desktop/WordToPdf.app done 
find . -type f \( -iname \*.doc -o -iname \*.docx \) -exec rm <> \; 
answered Jun 8, 2020 at 21:13 131 1 1 bronze badge

I had a similar situation, namely a folder of .doc (not .docx) files that needed to be batch converted to other formats such as .docx and .pdf using MacOSX 10.15.6 (Catalina). Products such as Doxillion could convert the files but much of the formatting was lost together with some of the text. I found that Pages could open the .doc files and made a pretty good job of maintaining the formatting and content when the files were exported. A solution using Automator and AppleScript to batch convert all .doc files in a folder is given by red_menace in response to question at: https://stackoverflow.com/questions/63803377/identify-path-to-file-in-applescript-script-as-part-of-automator-workflow

answered Sep 9, 2020 at 23:14 user1718097 user1718097

Apple Script version to run inside Automator and save on Desktop ConvertedPdf folder (see @dastra in this topic):

on run ConvertedPdfExists() repeat with aWordFile in input -- Get name and extension set theWordFilePath to aWordFile tell application "Finder" set to of the theWordFilePath end tell if theWordFileExtention is equal to "rtf" then tell application "Microsoft Word" activate open theWordFilePath set thePdfFileName to theWordFileName & ".pdf" set theNewFilePath to ((path to desktop folder) as string) & "ConvertedPdf:" & thePdfFileName set theActiveDoc to the active document save as theActiveDoc file format format PDF file name theNewFilePath close theActiveDoc saving no end tell end if end repeat return input end run on ConvertedPdfExists() set folderConvertedPdf to (path to desktop folder as string) & "ConvertedPdf" set askForClean to "Folder ConvertedPdf exists. Should I clean it before processing?" as string set askForCreate to "Folder ConvertedPdf does not exist at Desktop. Should I create it?" as string tell application "Finder" -- Folder exists if exists folder folderConvertedPdf then -- check if there are some files or folder inside set filesList to every file of folder folderConvertedPdf set foldersList to every folder of folder folderConvertedPdf set filesListSize to count of filesList set folderListSize to count of foldersList if folderListSize > 0 or filesListSize > 0 then display dialog askForClean with icon caution buttons ["No", "Yes"] default button "Yes" if the button returned of the result is "Yes" then -- clean folder delete (every item of folder folderConvertedPdf) end if end if else display dialog askForCreate with icon caution buttons ["No", "Yes"] default button "Yes" if the button returned of the result is "Yes" then make new folder at desktop with properties else display alert "Can't continue without output folder!" error number -128 end if end if end tell end ConvertedPdfExists