Skip navigation

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

43952 Views 57 Replies Latest reply: Mar 20, 2014 7:47 PM by SkyWatching RSS
  • Marlinespike Level 4 Level 4 (1,880 points)
    Currently Being Moderated
    May 30, 2011 5:34 PM (in response to spazek)

    Thank you, spazek!

     

    I already manually converted the files but I will try this as soon as practical and let you know how it works.

  • Rod Christiansen Level 1 Level 1 (5 points)
    Currently Being Moderated
    May 30, 2011 7:10 PM (in response to spazek)

    I found an very easy way to make .ppt to .pdf with automator

    Worked beautifully!

     

    Finder action: Selected files

    PowerPoint action: Covert Format of PowerPoint Presentations

    PowerPoint action: Quit PowerPoint

     

    Here is the screenshot: http://cl.ly/3V3e2q2N2u2t160N0D33

  • mbinder Level 1 Level 1 (0 points)

    I ran this, and it seemed to work, until Word warned me that the margins were outside the print area, and there was no script command to tell it how to proceed. Any ideas for that? All my docs will have that message...

  • macmee Level 1 Level 1 (0 points)
    Currently Being Moderated
    Sep 7, 2011 3:11 AM (in response to spazek)

    Spazek,

     

    I would like to THANK YOU 256 times (= the amount of .doc files I had to convert to pdf).

     

    Have a nice day.

  • charlesfromdoral Level 1 Level 1 (0 points)

    Very useful!

    I have a problem here. I only have in my library the Convert Format of PowerPoint related to Windows virtual machine version. I have Powerpoint for Mac 2011 installed. What I have to do? Thanks!

  • Rod Christiansen Level 1 Level 1 (5 points)
    Currently Being Moderated
    Sep 22, 2011 3:41 PM (in response to spazek)

    Spazek,

     

    What could I add at the end of the script to make the finder delete the Word file? Meaning, after the script runs, I only want the PDF to exist.

     

    Thanks

  • spazek Level 2 Level 2 (215 points)

    Hi!

    Sorry! I did not join here for a long time. Let´s start with the current question by Ron Christiansen:

     

    You could enter a line near the end of the AppleScript (the first one?)

     

    […]

                                            end if

                                  end tell


    tell application "Finder" to delete x

     

                        end try

              end repeat

    […]

     

     

     

    or in the GUI-Script:

     

    […]

      close theActiveDoc

                        end tell


                        tell application "Finder" to delete x

     

              end repeat

    […]

     

     

    This would be the most easy way.

     

    Spazek

  • jonnie5 Level 1 Level 1 (10 points)

    Hi I have the same problem.  I can't convince automator to use my powerpoint for mac version instead of of that installed under parrallels. 

     

    :-(

     

     

    Any ideas anyone?

     

    Thanks,

                   Jonnie

  • spazek Level 2 Level 2 (215 points)
    Currently Being Moderated
    Sep 28, 2011 3:59 AM (in response to jonnie5)

    Maybe I did not understand (i am no native english speaker) ...

    Using Automator Action to Convert ppt(x) to PDF opens PowerPoint on a Windows virtual machine version?

     

    If so, this would be really strange and you can try to use AppleScript as well.

    Use it in the way described in the example workflow above

     

     

    property theList : {"ppt", "pptx"}

     

    on run {input, parameters}

              set output to {}

     

              repeat with x in input

                        try

                                  set thePPT to contents of x

                                  tell application "Finder"

                                            set theFilePath to container of thePPT as text

     

                                            set ext to name extension of thePPT

                                            if ext is in theList then

                                                      set theName to name of thePPT

                                                      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"

                                                      set theOutputPath to (theFilePath & theFilename as string)

                                                      set PP to POSIX path of theOutputPath

                                                      tell application "Microsoft PowerPoint"

                                                                open thePPT

                                                                set theActivePPT to the active presentation

      save theActivePPT in theOutputPath as save as PDF

                                                                copy PP to end of output

      close theActivePPT

                                                      end tell

                                            end if

                                  end tell

      --tell application "Finder" to delete x

                        end try

              end repeat

      --tell application "Microsoft PowerPoint" to quit

     

              return output

    end run

     

     

    Spazek

  • sumtingwang Level 1 Level 1 (0 points)
    Currently Being Moderated
    Nov 8, 2011 2:18 PM (in response to spazek)

    Spazek, this is brilliant and has saved me much time, thanks!  I tried to dumb down the automator actions to the simplest steps, but Word keeps coming up the dialogue "Could not fire event."  Hmmm...

     

    I also need to convert the files to plain text and I am not familiar with AppleScript.  Problem is that the files contain English and another language, so they need to be encoded with Unicode 5.1, line breaks with CR only.  Could you tell me what needs to be changed in the script?

     

    Thanks!

  • spazek Level 2 Level 2 (215 points)

    Hi sumtingwang,

     

    Unicode 5.1 sounds as if you are using an older version of Word since the current Unicode version is Unicode 6.

    But ... truly said, i am absolutly not familiar with Unicode!

     

    To save a document as plain text you have to change following lines:

     

      set theFilename to theFilename & ".txt"

     

    and

     

      save as theActiveDoc file format format Unicode text text encoding 6 line ending type line ending cr only file name theFilename

     

    or in your case

     

     

      save as theActiveDoc file format format Unicode text text encoding 5 line ending type line ending cr only file name theFilename

     

    or maybe even

     

      save as theActiveDoc file format format text text encoding 5 line ending type line ending cr only file name theFilename


     

     

    I am not sure about the command "text encoding 5"

    From AS Dictionary:

    [text encoding unsigned integer] : Text encoding to use when saving out as text file

     

     

    Spazek


     


  • sumtingwang Level 1 Level 1 (0 points)
    Currently Being Moderated
    Nov 9, 2011 5:30 PM (in response to spazek)

    Spazek, thanks much for the reply.  I did end up loading the Word libraries into Applescript editor and changing the lines you mentioned.  However, after a bit more searching and fiddling with the command line utils, I found this and modified it a bit:

     

    find . -name *.doc -exec textutil -convert txt '{}' \;

     

    Navigate to the parent directory with the word files in Terminal--it is recursive.  Took all of about 20 seconds to convert 120 files. 

     

    Thanks again!

  • Aaron Lee Level 1 Level 1 (0 points)
    Currently Being Moderated
    Nov 13, 2011 8:59 PM (in response to spazek)

    Hi spazek,

     

    First of the very all, thank you very much for your scipts; I have been searching for a solution for a month.

    Wasting a lot of time, and your scripts help me so much!!!

     

    I registered an account so that I can say thanks to you.

     

    million thanks.

     

    Aaron

  • latavarius Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jan 29, 2012 1:45 PM (in response to spazek)

    THANK YOU Spazek!  You have made my life so much better with this converter-- I've been trying to work the bugs out of mine for some time.

     

    Best,

    Latavarius

  • allan_zip Calculating status...

    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?

Actions

More Like This

  • Retrieving data ...

Bookmarked By (6)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.