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

Previous Page 2
  • by Erko2,

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

    I think that would require more sophisticated understanding of AppleScript than I currently have.

     

    Just choose the the same folder at the second dialogue and it will output there without problem.

  • by stgrosso,

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

    I would but I've 664 files to convert. I just would find them in the Finder and past to the apps.. but I need to convert everything to the own destination path.

  • by Erko2,

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

    I know the feeling.  I went through folders individually myself. 

     

    The website I used to understand more about applescript was this one:  https://iworkautomation.com

     

    It seems to list most of the applescript commands, which is how I managed to adapt the script to convert to word format.  There might be something there that manages file paths a bit better. 

  • by onions83,

    onions83 onions83 Jan 13, 2015 2:58 PM in response to stgrosso
    Level 1 (0 points)
    Jan 13, 2015 2:58 PM in response to stgrosso

    Hi Stgrosso,

     

    Try this. It's probably not the cleanest way to do it but it basically tells the script to set the output folder as the input folder. Other than that can't help much, I'm no expert at scripting.

     

    --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

     

    -- 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 (theFolder 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

  • by brianmatute,

    brianmatute brianmatute Sep 20, 2015 3:18 PM in response to Erko2
    Level 1 (0 points)
    Sep 20, 2015 3:18 PM in response to Erko2

    Thank you so much! You help me a lot with this, i'm trying to use my docs (formerly Pages docs) into a many cloud services.

  • by brianmatute,

    brianmatute brianmatute Sep 20, 2015 3:25 PM in response to onions83
    Level 1 (0 points)
    Sep 20, 2015 3:25 PM in response to onions83

    Thank you!

  • by iEthan,

    iEthan iEthan Oct 4, 2015 8:16 PM in response to onions83
    Level 1 (0 points)
    Oct 4, 2015 8:16 PM in response to onions83

    You're a life saver. Just converted like 200 pages docs in about 1 minute.

  • by Borealys,

    Borealys Borealys Jul 20, 2016 4:26 AM in response to onions83
    Level 1 (4 points)
    Jul 20, 2016 4:26 AM in response to onions83

    I know this response was like a year and a half ago, but this script works AMAZINGLY well. I'm currently writing a second cookbook and as I'm gathering recipes, each recipe has its own Pages file. It might sound like an odd way to do it, but it allows me to keep everything organized into sections. At any rate, I needed each one converted into a PDF (for various reasons I won't bore you with). This script allows me to do just that in a batches. Do you realize the time you've just saved me? This is fantastic!

     

    Thank you for taking the time to do this. Wonderful stuff

  • by VikingOSX,

    VikingOSX VikingOSX Jul 20, 2016 5:05 AM in response to VikingOSX
    Level 7 (20,564 points)
    Mac OS X
    Jul 20, 2016 5:05 AM in response to VikingOSX

    I now have an AppleScript that can be run interactively, or as a drag and drop application. There is some assembly required (two-action Automator workflow needs to be created, and then copy/paste of AppleScript into Script Editor. I will post the code here if there is an interest.

     

    Features:

    • Interactive (double-click)
      • Calls an automator Ask for Finder Items workflow that allows multiple selection of files and folders
      • If Pages v5.6 or later, offers PDF export quality (good, better, best) selection
    • Drag and Drop support
      • Files and/or folders
      • Default PDF export quality is best, or default depending on Pages version.
    • Processing
      • Word and Pages documents
      • PDF written back to original file location
      • PDF extension forced visible in Finder
      • Pages version and PDF quality stamped in PDF document Finder comment field
      • On completion, notification panel slides in with processed file count
  • by mr.courteau,

    mr.courteau mr.courteau Sep 1, 2016 12:28 PM in response to stgrosso
    Level 1 (4 points)
    Sep 1, 2016 12:28 PM in response to stgrosso

    Here is a way simpler script for what you are asking. you just have to drag and drop the files on the script app and it will convert and export to the original location.

     

    Pages to PDF

     

    on open fs

      my proceed:fs

    end open

     

    on proceed:fs

      tell application "Finder"

      repeat with i from 1 to (get count of items in fs)

      if (name extension of item i of fs) is "pages" then

      set PDFfile to text 1 thru -7 of (item i of fs as text) & ".pdf"

      tell application "Pages"

      set mydoc to open (item i of fs) -- open input file in Pages 

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

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

      end tell

      end if

      end repeat

      end tell

    end proceed:

     

    Pages to word

     

    on open fs

      my proceed:fs

    end open

     

    on proceed:fs

      tell application "Finder"

      repeat with i from 1 to (get count of items in fs)

      if (name extension of item i of fs) is "pages" then

      set MSWfile to text 1 thru -7 of (item i of fs as text) & ".docx"

      tell application "Pages"

      set mydoc to open (item i of fs) -- open input file in Pages 

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

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

      end tell

      end if

      end repeat

      end tell

    end proceed:

  • by mr.courteau,

    mr.courteau mr.courteau Sep 1, 2016 12:43 PM in response to stgrosso
    Level 1 (4 points)
    Sep 1, 2016 12:43 PM in response to stgrosso

    Here is the way to do it, just drag and drop the files to convert on the script app, and it will export the converted files to the original location:

    Pages to PDF:

    on open fs

      my proceed:fs

    end open

     

    on proceed:fs

      tell application "Finder"

      repeat with i from 1 to (get count of items in fs)

      if (name extension of item i of fs) is "pages" then

      set PDFfile to text 1 thru -7 of (item i of fs as text) & ".pdf"

      tell application "Pages"

      set mydoc to open (item i of fs) -- open input file in Pages

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

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

      end tell

      end if

      end repeat

      end tell

    end proceed:

     

    PAGES to MS WORD

     

    on open fs

      my proceed:fs

    end open

     

    on proceed:fs

      tell application "Finder"

      repeat with i from 1 to (get count of items in fs)

      if (name extension of item i of fs) is "pages" then

      set MSWfile to text 1 thru -7 of (item i of fs as text) & ".docx"

      tell application "Pages"

      set mydoc to open (item i of fs) -- open input file in Pages

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

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

      end tell

      end if

      end repeat

      end tell

    end proceed:

  • by VikingOSX,

    VikingOSX VikingOSX Sep 2, 2016 9:34 AM in response to Lenny 118
    Level 7 (20,564 points)
    Mac OS X
    Sep 2, 2016 9:34 AM in response to Lenny 118

    I have posted a drag & drop Pages to PDF solution this morning. It expects at least Pages v5.5 with support for Yosemite and El Capitan.

Previous Page 2