Skip to content

Instantly share code, notes, and snippets.

@alanzchen
Forked from lambdamusic/keynote.scpt
Created September 4, 2023 04:57
Show Gist options
  • Save alanzchen/0313642a28cee06504baaedfaad5e73f to your computer and use it in GitHub Desktop.
Save alanzchen/0313642a28cee06504baaedfaad5e73f to your computer and use it in GitHub Desktop.
Apple Keynote: export presenter notes. This version accounts for skipped slides.
-- HOWTO:
-- after saving it, open with Script Editor (default) and run it
-- PREREQUISITES:
-- make sure your Keynote presentation is open in the background
-- AFTER EXPORT:
-- if you can't open the file due to encoding errors, open with Sublime (or another a text editor) and then "File / Save with encoding / UTF8"
tell application "Keynote"
activate
-- open (choose file)
tell front document
-- Get the name of the presentation.
set thePresentationName to name
-- Retrieve the titles of all slides.
set theTitles to object text of default title item of every slide
-- Retrieve the presenter notes for all slides.
set theNotes to presenter notes of every slide
-- Retrieve the skip status for all slides.
set theSkipStatus to skipped of every slide
end tell
end tell
set presenterNotes to ""
set actualSlideNumber to 0 -- Counter for actual slide number (excluding skipped slides)
repeat with a from 1 to length of theTitles
-- skip slides with empty notes and slides set as skipped
if not (item a of theNotes) = "" and not (item a of theSkipStatus) then
set actualSlideNumber to actualSlideNumber + 1
set presenterNotes to presenterNotes & "#### Slide " & actualSlideNumber & return & return
set presenterNotes to presenterNotes & item a of theNotes & return & return
end if
end repeat
set the clipboard to presenterNotes
do shell script "LANG=en_US.UTF-8 pbpaste > ~/Downloads/keynote-notes-" & quoted form of thePresentationName & ".md"
-- based on http://apple.stackexchange.com/questions/136118/how-to-print-full-presenter-notes-without-slides-in-keynote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment