Batch convert Word files to PDFs via Pages

Oct 20, '08 07:30:00AM

Contributed by: musselrock

This recent hint on automating print to PDF via Pages and AppleScript gave me the impetus to write an AppleScript for batch converting Word (or any other files that Pages can open) to PDF files (or any format that Pages can export to). Here's the script:

(* Drag and drop batch conversion of Word docs to PDF files using Pages*)
on open filist
    repeat with lvar in filist
        tell application "Finder"
            set thename to name of lvar
        end tell
        set nuname to text 1 thru text item -5 of thename
        tell application "Pages"
            activate
            set filname to (path to desktop folder as text) & nuname & ".pdf"
            set x to make new document with properties {path:filname}
            open lvar
            save document 1 in file filname
            close every window saving no
        end tell
    end repeat
end open
Save the script as a droplet. Drop a bunch of Word files on it, and they will be converted to PDF files on your desktop. For converting to other formats, in the line starting with set filname to, change pdf to rtf or txt.

[robg adds: This worked as described when I tested it. Note that Pages may not be able to handle all of Word's formatting option -- this will be especially true if you're using the new page layout format available in Word 2008. In those cases, you'll get the best results by saving as a PDF directly from Word.]

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20081016212447820