Skip to content

Instantly share code, notes, and snippets.

@loop
Created October 15, 2015 19:33
Show Gist options
  • Select an option

  • Save loop/7207134ed7ff7a288ee1 to your computer and use it in GitHub Desktop.

Select an option

Save loop/7207134ed7ff7a288ee1 to your computer and use it in GitHub Desktop.

Revisions

  1. loop created this gist Oct 15, 2015.
    28 changes: 28 additions & 0 deletions pagesToPDF.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    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