Lenny 118

Q: Batch convert Pages 5 files to PDF.

Is there a way or an app to batch convert Pages 5 files to PDFs ?

I need to convert about 200 files and doing them individually is

a long project.

 

Thanks in advance,

 

Lenny.

Posted on Nov 4, 2014 11:34 AM

Close

Q: Batch convert Pages 5 files to PDF.

  • All replies
  • Helpful answers

Page 1 Next
  • by PeterBreis0807,Solvedanswer

    PeterBreis0807 PeterBreis0807 Nov 4, 2014 2:56 PM in response to Lenny 118
    Level 8 (35,522 points)
    Mac OS X
    Nov 4, 2014 2:56 PM in response to Lenny 118

    Use Automator which comes with your System.

     

    Peter

  • by onions83,

    onions83 onions83 Dec 30, 2014 7:32 AM in response to PeterBreis0807
    Level 1 (0 points)
    Dec 30, 2014 7:32 AM in response to PeterBreis0807

    Hi Peter,

     

    I'm trying to do the same thing, but when I load Automator there doesn't seem to be an action that converts a pages file to PDF. Maybe I'm being really dense as I've not done anything with automator or apple script before.

    Any help would be appreciated.

     

    Keith

  • by PeterBreis0807,

    PeterBreis0807 PeterBreis0807 Dec 30, 2014 11:16 AM in response to onions83
    Level 8 (35,522 points)
    Mac OS X
    Dec 30, 2014 11:16 AM in response to onions83

    I am not in the position to do the workflow for you but the action would open a series of Pages files and print them, choosing PDF as the print.

     

    There is a separate Automator forum here and also websites dedicated to Automator. Google them.

     

    Peter

  • by VikingOSX,

    VikingOSX VikingOSX Dec 30, 2014 2:09 PM in response to Lenny 118
    Level 7 (20,544 points)
    Mac OS X
    Dec 30, 2014 2:09 PM in response to Lenny 118

    I am working on a modernized double-click/drag drop script — but it could take a few days to write and debug.

     

    It would evaluate what version(s) of Pages are installed, and what version(s) of Pages documents were selected/dropped on the application. Export to PDF would be attempted in the original application that created the given Pages document. The export syntax is different in older Pages versions than in Pages v5+.

     

    The principal reason for the second paragraph is that Pages 08 documents cannot be opened in Pages v5+, and that Pages '09 documents — if opened in Pages v5+ would be subject to content filtering — before the export to PDF. This could omit expected document content in the exported PDF.

  • by onions83,

    onions83 onions83 Jan 1, 2015 6:26 AM in response to PeterBreis0807
    Level 1 (0 points)
    Jan 1, 2015 6:26 AM in response to PeterBreis0807

    Thanks Peter, at least it gives me something to get started on.

     

    Here comes a long evening of google searches!

  • by onions83,

    onions83 onions83 Jan 1, 2015 6:28 AM in response to VikingOSX
    Level 1 (0 points)
    Jan 1, 2015 6:28 AM in response to VikingOSX

    That sounds exactly the sort of thing I'm looking for Viking. If you have any luck with it I'd love to see a copy of the script. Thanks

  • by onions83,

    onions83 onions83 Jan 2, 2015 5:31 AM in response to onions83
    Level 1 (0 points)
    Jan 2, 2015 5:31 AM in response to onions83

    Having spent some time searching the internet on how to do this with Automator I ended up trying to write my own in Applescript. More searching on how to do this and I stumbled onto this beautiful script from kenhotto, who has already done exactly what I was trying to do.

     

    --Select from where you will pick up the pages files

    set theFolder to choose folder with prompt "Select folder with original pages files :"

    --Do it

    tell application "Finder"

      set theNames to name of files of theFolder ¬

      whose name extension is "pages"

    end tell

     

    --Select where the PDF files will go

    set pdf_Folder to choose folder with prompt "Select folder where PDF files will go :"

     

    -- How many files to export

    set item_count to (get count of items in theNames)

     

    --Get files and export them

    repeat with i from 1 to item_count

     

      set current_file to item i of theNames -- get a file

      set lean_file to text 1 thru -7 of current_file & ".pdf" -- change the originalfile (.pages) to a .pdf name

      set out_file to (pdf_Folder as Unicode text) & (lean_file) -- get the fully qualified output name

      set in_file to (theFolder as Unicode text) & (current_file) -- get the fully qualified input file name

     

      tell application "Pages"

      set mydoc to open file in_file -- open input file in Pages

      export mydoc to file out_file as PDF --do the exporting

      close mydoc saving no -- close the original file without saving

      end tell

     

    end repeat

     

     

    display dialog "done" -- Job done


    We are constantly adding new pages documents to the folder I wanted to convert to PDF and so I tried re-running the programme on the already processed folders with the result that it simply adds the unconverted pages files to the existing folder of PDF's. It takes a bit of time and I'm sure there's a clever 'if clause' that will mean the programme doesn't even look at the already converted files, but this works for me. Problem solved. Thanks to kenhotto and everyone else for their input.

  • by TheAppleTim,

    TheAppleTim TheAppleTim Jan 4, 2015 7:06 AM in response to onions83
    Level 1 (65 points)
    Jan 4, 2015 7:06 AM in response to onions83

    Hey onions,

    Did you get your Script running with Pages 5 on Yosemite? If I try to to run, it quits after the first pages document opened.

  • by onions83,

    onions83 onions83 Jan 4, 2015 7:15 AM in response to TheAppleTim
    Level 1 (0 points)
    Jan 4, 2015 7:15 AM in response to TheAppleTim

    Hi TIm,

     

    Yeah I'm running OS X Yosemite 10.10.1 with Pages 5.5.1

    I copied the script into applescript then saved as an application. I then ran it and selected each folder in turn. I'm pretty sure there was a mixture of pages 09 and pages 5 files in the input folder but can't guarantee that, as they've now all been converted to pages 5. I'd try saving a couple of test files to a test folder and maybe include an 09 file to see if that causes any problems.

    To my amazement this all worked first time with no problems. I'm new to scripting so I'm probably not the nest person to ask.

    If all else fails it might be worth starting a new thread and asking someone to debug the script for you.

    Best of luck.

  • by Erko2,

    Erko2 Erko2 Jan 7, 2015 5:51 AM in response to onions83
    Level 1 (0 points)
    Jan 7, 2015 5:51 AM in response to onions83

    Hi guys,

    just wondered if I could have a bit of help getting this to work.  I seem to be the only person on earth who has never managed to get automator to work properly, so constantly find the 'watch me do' action just doesn't produce consistent results and needs a lot of resetting (often quicker to just do it manually). 

     

    The script keeps telling me "pages does not understand the 'export' message". Has anyone else come across this error message?

     

    I'm on yosemite 10.10.1 and pages 5.5.1 

     

    Any tips are much appreciated.

     

    Thanks,

    -G

  • by onions83,

    onions83 onions83 Jan 8, 2015 11:20 AM in response to Erko2
    Level 1 (0 points)
    Jan 8, 2015 11:20 AM in response to Erko2

    Hi Erko,

    although you should be able to run this in Automator theres no need, unless you want to more things with it. I simply copied the script into Applescript (found in your launch pad, I believe in utilities) and saved it as an application. You then just double click on the icon to run it and follow the instructions.

     

    easy peasy!

  • by Erko2,

    Erko2 Erko2 Jan 9, 2015 6:05 AM in response to onions83
    Level 1 (0 points)
    Jan 9, 2015 6:05 AM in response to onions83

    aha! thanks for the reply.  i do not know what i was doing wrong, but putting into script editor and just saving immediately seems to work now.

     

    i am also trying to adapt this to export word files, but I'm getting an error in this screenshot.

     

    i realise this is not really related to the original thread... but my limited knowledge of applescript is not really paying off.

     

    Screen Shot 2015-01-09 at 13.48.45.png

     

    here is the code I've been playing with:

     

    --Select from where you will pick up the pages files

    set theFolder to choose folder with prompt "Select folder with original pages files :"

    --Do it

    tell application "Finder"

      set theNames to name of files of theFolder ¬

      whose name extension is "pages"

    end tell

     

     

    --Select where the Word files will go

    set docx_Folder to choose folder with prompt "Select folder where Word files will go :"

     

     

    -- How many files to export

    set item_count to (get count of items in theNames)

     

     

    --Get files and export them

    repeat with i from 1 to item_count

     

      set current_file to item i of theNames -- get a file

      set lean_file to text 1 thru -7 of current_file & ".docx" -- change the originalfile (.pages) to a .docx name

      set out_file to (docx_Folder as Unicode text) & (lean_file) -- get the fully qualified output name

      set in_file to (theFolder as Unicode text) & (current_file) -- get the fully qualified input file name

     

      tell application "Pages"

      set mydoc to open file in_file -- open input file in Pages

      export mydoc to file out_file as docx --do the exporting

      close mydoc saving no -- close the original file without saving

      end tell

     

    end repeat

     

     

     

     

    display dialog "done" -- Job done

  • by Erko2,

    Erko2 Erko2 Jan 9, 2015 6:22 AM in response to Erko2
    Level 1 (0 points)
    Jan 9, 2015 6:22 AM in response to Erko2

    Just figured out the WORD export options too!

     

    This is handy!  Thank you guys for the help in getting this script running.  I've been itching to get this working again since upgrading to yosemite. 

     

     

    --Select from where you will pick up the pages files

    set theFolder to choose folder with prompt "Select folder with original pages files :"

    --Do it

    tell application "Finder"

      set theNames to name of files of theFolder ¬

      whose name extension is "pages"

    end tell

     

    --Select where the Word files will go

    set docx_Folder to choose folder with prompt "Select folder where Word files will go :"

     

    -- How many files to export

    set item_count to (get count of items in theNames)

     

    --Get files and export them

    repeat with i from 1 to item_count

     

      set current_file to item i of theNames -- get a file

      set lean_file to text 1 thru -7 of current_file & ".docx" -- change the originalfile (.pages) to a .doc name

      set out_file to (docx_Folder as Unicode text) & (lean_file) -- get the fully qualified output name

      set in_file to (theFolder as Unicode text) & (current_file) -- get the fully qualified input file name

     

      tell application "Pages"

      set mydoc to open file in_file -- open input file in Pages

      export mydoc to file out_file as Microsoft Word --do the exporting

      close mydoc saving no -- close the original file without saving

      end tell

     

    end repeat

     

     

    display dialog "done" -- Job done

  • by stgrosso,

    stgrosso stgrosso Jan 13, 2015 12:26 AM in response to Erko2
    Level 1 (0 points)
    Jan 13, 2015 12:26 AM in response to Erko2

    Hi,

     

    can you help me with this, please?

     

    The script works very well. Just I want to export the file automatically to the same path file without to be asked for. I mean: I need to export all my pages files to docx and I want the destination folder to be the path folder. Thanks. S.

Page 1 Next