Multiple Docs to PDF

Discussion in 'Mac Basics and Help' started by Newmacer2, Oct 20, 2013.

  1. Newmacer2 macrumors regular

    Joined:
    Aug 14, 2009
    Location:
    Denver Colorado
    #1
    I have about 100 LibreOffice documents I want to convert to PDF. Is there a way to process multiple documents to PDF without doing each one individually?
    Thanks.
     
  2. Nickwell24, Oct 20, 2013
    Last edited: Oct 20, 2013

    Nickwell24 macrumors regular

    Joined:
    Nov 13, 2008
    #2
    Due to using Libre you'll have to change a few steps, but this works for Microsoft Word. If your files aren't in the doc or docx format change the property theList line to show the proper format. Also replace "Microsoft Word" with the LibreOffice Writer application name.

    Easiest way is this:

    1) Open Automator and select Application
    2) Drag "Run Applescript" into the right work area.
    3) Past the following into the "Run Applescript" box. (removing everything previously included)

    Start of code

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

    on run {input, parameters}

    set output to {}

    tell application "Microsoft Word" to set theOldDefaultPath to get default file path file path type documents path

    repeat with x in input

    try

    set theDoc to contents of x

    tell application "Finder"

    set theFilePath to container of theDoc as text

    set ext to name extension of theDoc

    if ext is in theList then

    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"

    tell application "Microsoft Word"

    set default file path file path type documents path path theFilePath

    open theDoc

    set theActiveDoc to the active document

    save as theActiveDoc file format format PDF file name theFilename

    copy (POSIX path of (theFilePath & theFilename as string)) to end of output

    close theActiveDoc

    end tell

    end if

    end tell

    end try

    end repeat

    tell application "Microsoft Word" to set default file path file path type documents path path theOldDefaultPath

    return output

    end run



    End of Code

    4) Go to Save... and save this to your desktop - I called mine Doc to PDF. Then drag the 100 documents on top of Doc to PDF icon and drop them onto the icon. Word will then open all the of documents in order to convert them and in the original folder you'll now have both a .doc/x and .pdf version.
     
  3. Newmacer2 thread starter macrumors regular

    Joined:
    Aug 14, 2009
    Location:
    Denver Colorado
    #3
    Thanks

    Thank you very much! You must be a genius or a very good programmer. I appreciate your help.
     

Share This Page