-
-
Save lambdamusic/e3c145fc1724cadc8c0120e20f2eef9f to your computer and use it in GitHub Desktop.
-- 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 | |
end tell | |
end tell | |
set presenterNotes to "" | |
repeat with a from 1 to length of theTitles | |
-- skip slides with empty notes | |
if not (item a of theNotes) = "" then | |
set presenterNotes to presenterNotes & "#### Slide " & a & ": " & item a of theTitles & return & return | |
set presenterNotes to presenterNotes & "##### Presenter Notes: " & return & item a of theNotes & return & return | |
end if | |
end repeat | |
set the clipboard to presenterNotes | |
do shell script "pbpaste > ~/Desktop/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 |
Works on Monterey, but saved file name had no file extension. I manually added .txt and it was fine.
To support UTF-8 encoding (which prevents “broken” special characters), change the last line to
do shell script "LANG=en_US.UTF-8 pbpaste > ~/Desktop/keynote-notes-" & thePresentationName & ".md"
Great script. The last line which exports to a Markdown file should be changed, though... as written, if the presentation name has spaces, the script will terminate the name after the first word and not include the extension. @michaelzed notes this issue above. Changing the line to read as below will fix the problem:
do shell script "pbpaste > ~/Desktop/keynote-notes-" & quoted form of thePresentationName & ".md"
Thanks @frankrausch @RunsOnCoffee, last line updated
Thanks for this script. It worked perfectly for me.
Worked so great; thanks very much!
(I couldn't figure out how to do that "save with encoding" process provided in the comments, so just created a blank new script in the Script Editor, and copied/pasted the code into that.)
Does anyone get an error: "Keynote got an error: Can't get document 1."?
The Result I get is: error "Keynote got an error: Can’t get document 1." number -1728 from document 1"
edit
Never mind, figured it out. BITDEFENDER was blocking the document. Now works like a charm.
Epic script to replace the older version, was having to back save keynotes to the 09 version until now. Pasted straight into script editor and it worked perfectly.
For anyone who doe not want "skipped" slides to appear in the export, here is a version that accounts for that:
https://gist.github.com/alanzchen/0313642a28cee06504baaedfaad5e73f
Is there a way to exclude skipped slides?
Just add whose skipped is false
at the end of the two lines that retrieve the titles and the presenter notes
set theTitles to object text of default title item of every slide whose skipped is false
set theNotes to presenter notes of every slide whose skipped is false
Thank you, so useful
Used it today with Keynote 14 and Ventura. Thanks again.
This works great! Is there anyway to include images in MD file? For instance, image1