Keynote: Add a Folder of PNGs to This Slide

keynoteWhat, you might ask yourself, is the point of this script? Can’t I just drag images into Keynote? Well, replies this hastily anthropomorphised bunch of code, you could do that. But your images will be strewn hither and thither, rather than nicely centered on your slide. Quod erat, as my uncle would say, demonstrandum.

Download Add-a-folder-of-PNGs-to-this-slide.rb.zip.

The source code is sleeping gently, just down there. Hush now, source code.

#!/usr/bin/env ruby -w
# rb-appscript code by Ian Haigh : http://ianhaigh.com/
# Fri Dec  4 10:21:35 EST 2009

require 'rubygems'
require 'appscript'
require 'osax'

sa = OSAX.osax('StandardAdditions')
app = Appscript.app('Keynote.app')

source = sa.choose_folder(:with_prompt => "Choose source:").to_s

current = app.slideshows[0].current_slide

Dir.chdir(source)
Dir.glob("*png") do |f|
	p f
	app.add_file(current, :path => [source, f].join("/"))
end
This entry was posted in keynote. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • What’s this all about then?

    rb-appscript is a powerful way to automate your Mac. It's similar to Applescript but it's built in Ruby, which means you get to leverage that language's powerful syntax and libraries. Giving you more time to make toasted sandwiches. You want long-winded explanations? We got those.

    Please note that these scripts are by no means bulletproof, and are intended to provide examples of application scripting. I take no resposibility for any loss of data or mishaps; you download and run everything at your own risk. That said, I use all of these scripts in a production environment every day (well – more accurately, I use some of these scripts in a production environment most days).