Script for Keynote to export slides as individual MOVs

I keep getting the "Expected end of line, etc. but found identifier." using this script:


tell application "Keynote"

  set theDoc to the front document

  set slideCount to count of slides of theDoc


  -- Get the path of the current Keynote presentation

  set presentationPath to theDoc's file as string


  -- Get the folder containing the presentation file

  set presentationFolder to (POSIX path of presentationPath) & ".."


  repeat with i from 1 to slideCount

    -- Set the name of the output file

    set outputName to "Slide " & i & ".mov"


    -- Set the path of the output file

    set outputPath to presentationFolder & outputName


    -- Export the slide as a QuickTime movie to the output path

    export theDoc to file outputPath as QuickTime movie using settings {image quality:best, slide duration:5}

  end repeat

end tell



Posted on May 2, 2023 3:11 PM

Reply
Question marked as Top-ranking reply

Posted on May 2, 2023 4:00 PM

Keynote's export command (at least OMM) has no 'using settings' parameter:


COMMAND SYNTAX
export document ¬
     to file ¬
     as export format ¬
     with properties export options


where export options are listed as:



So there is no 'image quality' nor 'slide duration' parameter.


Where did you get that script from? If it's old, it's possible that the commands have changed over time.

Similar questions

11 replies
Question marked as Top-ranking reply

May 2, 2023 4:00 PM in response to inritool

Keynote's export command (at least OMM) has no 'using settings' parameter:


COMMAND SYNTAX
export document ¬
     to file ¬
     as export format ¬
     with properties export options


where export options are listed as:



So there is no 'image quality' nor 'slide duration' parameter.


Where did you get that script from? If it's old, it's possible that the commands have changed over time.

May 3, 2023 9:59 AM in response to Camelot

I took a dive into this, and it might not be so hard...


export includes a 'skipped slides' option. I edited the script to hide all but one slide then run the export, which has the effect of exporting just one slide per movie file.


It won't help if your presentation already has hidden slides (it assumes are slides are valid), but that can be worked out if it's an issue.


tell application "Keynote"
	set theDoc to the front document
	set slideCount to count of slides of theDoc
	
	-- Get the path of the current Keynote presentation
	set presentationPath to theDoc's file as string
	
	-- Get the folder containing the presentation file
	set presentationFolder to (POSIX path of presentationPath)
	
	repeat with i from 1 to slideCount
		
		-- hide all the slides
        set skipped of every slide of theDoc to true
        -- enable just the current slide
		set skipped of slide i of theDoc to false
		-- Set the name of the output file
		set outputName to "Slide " & i & ".m4v"
		
		-- Set the path of the output file
		set outputPath to presentationFolder & outputName
		
		-- Export the slide as a QuickTime movie to the output path
		export theDoc to outputPath as QuickTime movie without skipped slides
	end repeat
end tell


You should end up with a series of .m4v files, one per slide in the presentation.

May 10, 2023 9:21 AM in response to inritool

I'm using the exact same script I posted above, and that you show:


use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Keynote"
	set theDoc to the front document
	set slideCount to count of slides of theDoc
	
	-- Get the path of the current Keynote presentation
	set presentationPath to theDoc's file as string
	
	-- Get the folder containing the presentation file
	set presentationFolder to (POSIX path of presentationPath) & "."
	
	repeat with i from 1 to slideCount
		
		set skipped of every slide of theDoc to true
		set skipped of slide i of theDoc to false
		-- Set the name of the output file
		set outputName to "Slide " & i & ".m4v"
		
		-- Set the path of the output file
		set outputPath to presentationFolder & outputName
		
		-- Export the slide as a QuickTime movie to the output path
		export theDoc to outputPath as QuickTime movie without skipped slides
	end repeat
end tell


The remaining possibility is that there's some element in the first slide that's breaking the export... two things to try.


1 is simplify, simplify, simplify - I know you say it fails on multiple presentations, but are they simple presentations or complex ones? for example, try with a set of slides that have just text on them (theory being that maybe Keynote can't export slides that contain video or certain other media.

2 would be to edit the script wrap the export in a 'try' statement:

    try
		export theDoc to outputPath as QuickTime movie without skipped slides
    end try


This will catch errors, rather than stop the script at the first error - it might indicate that certain slides are throwing the error, while other slides are fine (notwithstanding point 1 above). If this change manages to export slides 2, 3, 5 and 7, you know there's something particular about the other slides.


May 2, 2023 4:22 PM in response to inritool

> If I delete that line... do you suppose it will work?


If you remove that line, you won't get anything, since that's what's initiating the export.


You'll need to rework that line to match the properties that Keynote's export command understands.


Off hand I don't know how to export individual slides with specific timers, and I don't see anything obvious in the parameters it does support.

May 9, 2023 1:08 PM in response to inritool

Sorry to hear that. It seems to work on my machine, on a sample presentation.


That leaves three possible scenarios that I can think of off-hand.


1 - some issue with the presentation itself (have you tried a different one?)

2 - you're running an older version of Keynote and the command structure is different (which version are you running?)

3 - some permissions error - is the destination folder local or remote? is it locked?

May 2, 2023 4:05 PM in response to Camelot

I have been using ChatGPT to try and automate this export process. Currently, I export individual Keynote slides to MOV files so the animations and fonts will hold true across other presentation software like ProPresenter, PowerPoint, Google Slides, etc. I was hoping a script could do it for me. If I delete that line... do you suppose it will work?


May 3, 2023 12:15 PM in response to Camelot

This script saved with no error... which is a step further! Running the script returned this error:


error "Keynote got an error: The document “GAME - Favorite Hero” could not be exported as “GAME - Favorite Hero.keySlide 1”. Your most recent changes might be lost." number 6


In the file - it hid all slides except slide 1 but did not save any of them as m4v files.


I am assuming I do not need to edit this script for the export path or file name. Your script has that all automated.


Thanks for looking at this - it would save me a TON of time if there was a way to get it to work.


I received the same error and Keynote behaved the same way with multiple files. It hides all subsequent slides after slide 1.

May 10, 2023 3:46 AM in response to Camelot

I have tried multiple presentations, and it behaves the same way.


Keynote is version 13.0 (7036.0.126)


Its a local folder with no special permissions set.


Error is the same: error "Keynote got an error: The document “IG_swipe_Screens_MeetTheTeam” could not be exported as “IG_swipe_Screens_MeetTheTeam.keySlide 1”. Your most recent changes might be lost." number 6


The document does hide all other slides except the first one... but stops at the export function.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Script for Keynote to export slides as individual MOVs

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.