You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how do I use automator to batch convert doc to pdf?

Although I thought it would be an easy thing to do I'm finding it difficult to get much info or help on this. The few scripts and instructions I have discovered on the web don't seem to work. I tried to create one with a get file and then convert word docx. It creates the pdfs but they are corrupted and can't be opened.


Any ideas anyone?

Macpro, Mac OS X (10.6.4)

Posted on May 11, 2011 12:06 AM

Reply
90 replies

Mar 11, 2013 2:39 PM in response to zalamander

I will vent, but for a reason.


I have followed all steps in entire post and I still do not have a functioning app/workflow (I really don't care how this is called; I just need it to work). I also downloaded script that someone else posted and it is NOT working.


I'm not sure why with all the geeks ot there it is so difficult to construct a SIMPLE, FUNCTIONING (=works on latest iOS) application or workflow (call it whatever you want) IN ONE SINGLE POST, as opposed to posting FRAGMENTS of codes that do nothing but confuse the end user and take hours to put together; and force most in the position where opening each and every doc file and saving it as PDF is far more time efficient than reading through these posts that provide variations upon variations of NON-functioning advice.


It's plain and simple: this is what is needed- because this is exactly what Adobe Prof offers.


IOS 10.8.2

Office 2011


(1) (multiple) select doc/docx files in Finder

(2) right click

(3) choose an option to convert from doc to PDF

(4) option runs and

(4) a: takes all doc/docx files

(4) b: converts files to PDF (does NOT delete doc. files)

(4) c: puts newly created PDF files INTO SAME FOLDER WHERE DOC/DOCX files are.


Is is so difficult to create ONE post that, in ONE PLACE explains step-by-step how and app/workflow achieves steps listed (1)-(4)?

Jun 7, 2013 4:51 PM in response to mohair_slim

Hi,

(this is an example for an already opened Word document only)


tell application "Microsoft Word"

set theDoc to path of active document as alias


tell application "Finder"

set ext to name extension of theDoc

set x to (length of ext) + 2

set theName to (text 1 thru -x) of (theDoc as string)

set thePDF to theName & ".pdf"



--IF FILE ALREADY EXISTS ADD A NUMBER (INCREASING)

if (exists file thePDF) then

set n to 1

set thePDF to theName & "_" & n & ".pdf"

repeat until (exists file thePDF) is false

if (exists file thePDF) then

set n to n + 1

set thePDF to theName & "_" & n & ".pdf"

end if

end repeat

end if


end tell


set theActiveDoc to the active document

try


save astheActiveDocfile formatformat PDFfile namethePDF

on error


display alert "Error"


end try


-- close theActiveDoc


end tell

It looks for existing files and adds a number (or increases it) : if there is a "test_1.pdf" ist will save it as "test_2.pdf" ...


I will add the necessary lines to the script on page 1 the next days...


Spazek

Jun 11, 2013 3:09 PM in response to mohair_slim

So here a modificated version of the script on page 1 to use in theRun AppleScript Action:



property theList : {"doc", "docx"}


on run {input, parameters}

set output to {}

tell application "Microsoft Word" to set theOldDefaultPath to get default file pathfile path typedocuments path

repeat with x in input

try

set theDoc to contents of x


tell application "Finder"

set ext to name extension of theDoc

if ext is in theList then

set x to (length of ext) + 2

set theName to (text 1 thru -x) of (theDoc as string)

set thePDF to theName & ".pdf"


if (exists file thePDF) then

set n to 1

set thePDF to theName & "_" & n & ".pdf"

repeat until (exists file thePDF) is false

if (exists file thePDF) then

set n to n + 1

set thePDF to theName & "_" & n & ".pdf"

end if

end repeat

end if




tell application "Microsoft Word"

open theDoc

set theActiveDoc to the active document


save astheActiveDocfile formatformat PDFfile namethePDF

copy (POSIX path of thePDF) to end of output


closetheActiveDoc

end tell


end if

end tell



end try

end repeat


tell application "Microsoft Word" to set default file pathfile path typedocuments pathpaththeOldDefaultPath



return output

end run




--Spazek

Nov 10, 2013 5:09 PM in response to spazek

I want to thank you for your scripts, they have helped me a lot, but, if you have time, I have two questions.


1) This conversion does not mess witht the content or format of your documents, correct? (It doesn't appear to).


2) How can I alter this to work with Pages '09 files? (Also, if possible the new Pages '13 as well, but mainly the Pages '09). If you have time to reply I would appreciate it, if not you've already helped me a ton.



Thanks again!

Dec 18, 2013 7:52 PM in response to zalamander

These are wonderful - but I'm having a little trouble getting it to work. Perhaps it has to do with using Mavericks?


I am trying to get this to work a different way. I want to be able to select a Word file in finder and have that file be converted into PDF. This could be a service, which is really just executing an AppleScript. In fact, what I would do is have Hazel watch a particular folder and convert every file in that folder to PDF.


My AppleScripting skills are still quick elementary. Can anyone help with this? Your help would be very appreciated.

Dec 20, 2013 1:34 PM in response to matt.bowlby

Hi


I'm in a similar situation and would very much like some help too if there is anyone willing and able out there. My stuation is that I have a large number of .doc files of varying ages but mostly from around 1992-1994.


I'm using a Mavericks installation with Office Mac 2011 I've just bought, all the latest versions, all software has been updated. I'm finding that I can open all the files I want to convert using Word if I open Word and use the File->Open option on single files, so all the files are "openable". However, if I use the Automator system or some of the excellent scripts posted earlier in this thread I just get no output from the script, and no PDFs. The problem seems to be that on some of the files I get the message in the image attached below, even when I try opening them by double-clicking rather than using the File->Open menu.


My gut feeling is that this is the problem that the Automator or the script are running up against, can anyone suggest how I might get this to work, if not I've just thrown top $s down the drain 😟


In a nutshell I believe that for some reason the script and automator are unable to open these files even though the File-Open option can. I really don't want to have to open them all one by one and then save them individually as PDFs!


Thank you,


Quentin.


User uploaded file

Dec 27, 2013 5:46 AM in response to zalamander

Try the PDF export of OpenOffice.
MS Office for Mac is quite bad with pdfs (and other stuff) I had some font issues which OpenOffice solved. Considering how long OO supports pdf exports it probably supports all forms, links and such too. Or if you have Windows use Office 2007 SP2 or later those have an actual save as PDF option and not just some pdf printer that poses as a pdf saving option.


Not very convenient but if it is only very few files, online converters do the trick. They eat just about everything and most produce very good results with support for just about anything.
as an example.
http://www.pdf-file-converter.com/create-pdf-from-ms-office-on-mac/

Mar 4, 2014 3:42 PM in response to spazek

spazekI'm having a difficult time trying to do this...


I am opening Automator

Choosing Application

Draging Run Apple Script to the workflow area

Earasing all information from the script and pasting your script in the area.

Saving the application to my desktop with the name of "PDF Maker"


For a test, I am draging a .doc file over the PDF Maker and dropping the file to run the script.


Then I get this error


The action "Run AppleScript" encounted an error.

Check the actionʼs properties and try running the workflow again.


What am I doing wrong?

I am using Word 2011 (student version)

OSX 10.9.2


Any help would be great. Thanks.

how do I use automator to batch convert doc to pdf?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.