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

Apr 23, 2012 4:47 AM in response to latavarius

I'm trying to run Spazek's script to convert a folder of docs to pdfs but am getting the response

"Move finder items was not supplied with the required data"

When I run the scipt Word 2011 opens and launches each doc but when I close each file I get the message "Word could not fire event".

I've followed the instructions closely; Get specified Finder items > Run AppleScript > Move Finder items

not sure what I'm doing wrong. Any help?

Jun 20, 2012 6:41 AM in response to spazek

Hi Spazek,


Your convert .doc to PDF applescript worked a treat. Brilliant. I tried to follow it but its too much for me I would really need a script that saves the current word document (front) as a PDF in the same folder as the current word document. So I don't have to do: save as / PDF / in folder. I tried for a day to invent an automator script for this but it didn't work.

Jun 25, 2012 3:34 PM in response to mohair_slim

Hi mohair_slim,


again i am not sure if i got it:

You are talking about a current active word document that is already saved as a doc (or docx)?

If so, try this:


tell application "Microsoft Word"

set theOldDefaultPath to get default file pathfile path typedocuments path


set theDoc to path of active document as alias

tell application "Finder"

set theFilePath to container of theDoc as string

set ext to name extension of theDoc

set theName to name of theDoc

copy length of theName to l

copy length of ext to exl


set n to l - exl - 1

copy characters 1 through n of theName as string to theFilename


set theFilename to theFilename & ".pdf"

end tell



set default file pathfile path typedocuments pathpaththeFilePath

set theActiveDoc to the active document


save astheActiveDocfile formatformat PDFfile nametheFilename


-- close theActiveDoc



set default file pathfile path typedocuments pathpaththeOldDefaultPath

end tell


Spazek

Jun 25, 2012 4:15 PM in response to spazek

Upps i mixed to scripts .. of course the one above would work too...


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) + 1

set thePDF to (text 1 thru -x) of (theDoc as string) & "pdf"

end tell


set theActiveDoc to the active document

try


save astheActiveDocfile formatformat PDFfile namethePDF

on error

display alert thePDF & " already exists"

end try


-- close theActiveDoc


end tell

Jun 26, 2012 12:36 PM in response to spazek

Spazek,

Thanks a zillion on this. I have a ton of documents that need to be converted to PDF and I had tried writing several versions of an automator script, and applescript, with no success. I took what you had here and added rich text format to the file format as well. Works BEAUTIFULLY!!!


Thanks again for sharing!!! !https://discussions.apple.com/images/emoticons/grin.gif|___jive_emoticon_name=grin|jivemacro=emoticon|class=jive_macro jive_emote|src=https://discussions.apple.com/images/emoticons/grin.gif!

Sandra


BTW, This was accomplished on Lion!

Dec 20, 2012 4:38 AM in response to spazek

This is very helpful. I have been trying to achieve this for some time now through Automator but finally stumbled on this thread.


Two questions:


  1. Is it possible to amend the script so that other file formats can be channeled through it and once, f. ex. Pages or Excel?
  2. In stead of saving the PDF version in the same location, how would one change the script to that it would add a folder named "PDF" in the current location and save the docs there?


On a different note, I seriously considering purchasing AppleScript: The Missing Manual.

Dec 21, 2012 8:49 AM in response to zalamander

I love this app but I have a serious issue and i wonder if it is the script or me. First, it must be said that I have ZERO knowledge of scripts and only heard of "automator" today. I am new to OSX. Let me also say that I want to batch convert multiple .doc and .docx files to PDF. I would be happy if they convert individually to PDF but I would be more pleased of the all files selected were BOTH converted into PDF AND combined into a single PDF file.


All of the bove having been said, my issue with the "app" posted above (I downloaded and tried it successfully...thank you) is that when it comes time to select a folder, I NEED to navigate through a lot of folders in order to get to the desired folder. But when I click ONE folder...the very first folder....the app thinks this first folder is the folder where my desired files are stored and it takes control away from me and proceeds to the next step in the script. My files are DEEPLY layered in my company's file server. For example: M:/folder1/folder2/folder3 I want to select folder 3....but when I click on folder 1 the app takes over and I cannot get to the files I need to convert.


Let me also say, I found a work around. But it seems unnecessary. To get this app to work for me, I first went to finder......then I slected the exact folder I needed, which hold my DOC files and I moved it to the far left pane in FINDER under "FAVORITES." Now, when I use the "Convert to PDF" app posted here, I simply click my desired folder under FAVORITES. I can and I will continue to do this if I have to do so, but I think this is just a case of the app script needing updated. (as a side note, I will also have to remove the same folder from my favorites, every time I want to use this work around method...after all, I do not want a huge list of favorites as time goes on).


Am I the only one having this problem? If yes, I wonder what is going on?


Can anyone help?


Thank you

Kevin

Jan 20, 2013 7:44 PM in response to spazek

I was thrilled to find this script for batch converting Word files to PDF, but unfortunately it's not working for me. I wonder whether anyone has had luck with it in Mountain Lion OS X 10.8 with Word 2011 (14.2.5)?


When I compile the script, I get an error on the line


save astheActiveDocfile formatformat PDFfile nametheFilename


Automator (or AppleScript) seems to expect the end of line after the first 'format." If I put "format PDF" in quotation marks, it compiles, but I still get an error on execution of the script:


"Can't make (alias "filepath/filename") into type <<class utf8>>"


Has anyone had these errors and/or found a solution?


Word's automator actions for automator are all grayed out for me (on another computer, they are active, but still don't execute without an error). I also tried CUPS-PDF desktop printer -- Word opened the file, but won't print to PDF. (Neither of these solutions is related to this script, but I wanted to say what else I'd tried.)

Jan 31, 2013 3:35 AM in response to spazek

Spazek, if there was some way I could send you some $ I would. I use your script every day. Thank you.


The only way it could possibly be improved for me is that if you try to save and there is already a .pdf with the same name it gets an error. In a perfect world there would be a dialog box asking if you want to replace the existing document. Not complaining though!

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.