Skip to content

Instantly share code, notes, and snippets.

@chatchavan
Last active September 9, 2020 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chatchavan/241c943880247f87660ffac54e006392 to your computer and use it in GitHub Desktop.
Save chatchavan/241c943880247f87660ffac54e006392 to your computer and use it in GitHub Desktop.
AppleScript for using Keynote PNG exports with in video editing
-- Export the Keynote presentation of the front window to a folder on the desktop as PNG
tell application "Finder"
set folderName to "Keynote export"
set folderPath to POSIX path of (path to desktop) & folderName
-- trash the previous export, if any
if ((exists folder (folderName) of desktop)) then
move my (POSIX file folderPath) to the trash
end if
-- make a new folder
make new folder at desktop with properties {name:folderName}
-- export
tell application "Keynote"
tell front document
export as slide images to POSIX file folderPath with properties {image format:PNG}
end tell
end tell
end tell
-- Make Finder select the corresponding PNG of the current slide
-- get the slide number
tell application "Keynote"
tell document 1
set slideNumber to slide number of the current slide
end tell
end tell
-- compose the path name
set slideFileName to text -3 thru -1 of ("000" & slideNumber)
set slideFilePath to POSIX path of (path to desktop) & "Keynote export/" & slideFileName & ".png"
log slideFilePath
-- select the path
tell application "Finder"
select my (POSIX file slideFilePath)
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment