keynote plot automation help

I am very new for apple script, just get start. I basically want to create an automation keynote.
basically, I want to automatically insert figures from a folder to a keynote presentation.
Can anybody give me a hand? or some leads I can start…

hello. I try to get started but encounter some basic error

I want to select all png files from a folder
set the_files to (list folder (choose folder) whose name extension is [“PNG”]),
however, the error message is ‘cant get alias … who’s name extension =png’.

my other question is, after I got all list of png files. how can I compare the file name, because I want to plot png files with the same series number(reflect in the file names) in the same keynote page.
thanks a lot
best regards

Hi yangliudk. Welcome to MacScripter.

Our “Automator” forum is for help with workflows for the Automator application rather than for writing AppleScript code. I’ll ask for this topic to be moved to our “AppleScript | Mac OS X” forum.

I’m afraid here are several problems with your code.

The ‘whose’ construction isn’t supported by AppleScript directly, but is implemented by many applications which support AppleScript! In this case, the application should be either the Finder or System Events, both of which can search for files and folders and both understand what a ‘name extension’ is. With a ‘whose’ filter, you also have to provide an expression describing what kind of object you want, such as ‘files of source_folder’ in the following code. A ‘file’ is something which has a ‘name extension’. This returns the names of all the matching files in the chosen folder:

set source_folder to (choose folder)
tell application "System Events"
	set the_files to name of files of source_folder whose name extension is "png"
end tell

‘list folder’ is a deprecated command and shouldn’t be used. In any case, it’s not understood in the context of a ‘whose’ filter.

Square brackets — [ ] — shouldn’t be used either as they’re not part of AppleScript. In fact no brackets are needed at all around “PNG” in your original code.

That will be a matter of examining the text of each of the names returned above. If you can show us some example file names and what you want from them, people here should be able to help. It sounds as if you’ll also need to ask about getting information from Keynote.