Wednesday, October 14, 2009

Convert Keynote / iWork 2009 to 2008

If you're like me, you tried Keynote 2009 and - while Keynote continues to be a superior presentation tool - decided that it wasn't worth the cost of upgrading. If you're even more like me, you created at least one presentation in Keynote 2009 during the trial (or converted a Keynote 2008 presentation to Keynote 2009 and tweaked it a bit), and were then quite dismayed to find that you could not open the Keynote 2009 file in Keynote 2008 at all. This is a big problem after the trial runs out - it leaves you with presentation material you can't recover!

The Keynote 2008 "file format" is really a directory structure. That is, each .key file is really a directory containing the information that Keynote uses to reconstruct the presentation. In Keynote 2009 this changed to a "flat file" format - they .key file really is a single file. Investigation reveals pretty quickly that the contents of that file are quite similar to the contents of the 2008 directory. A post by linux4research cleared this up - the 2009 format is actually a zipped archive! So half the battle is to simply rename the .key file to a .zip file, unzip it, then rename the unzipped folder with a .key extension. This still won't open in Keynote 2008, though. Luckily the other half of the battle is equally as simple. In they .key folder, open the file index.apxl, find the string key:version= followed by a quoted string that is probably something like 92008xxxxxx. Replace the number with 72007061400.

Anyways, here is a shell script that automates this process. I haven't tested it too extensively, but the basic idea should work. I haven't had experience with other iWork '09 programs (Pages, Numbers), but reportedly the differences are essentially the same, so it may work with them as well if you replace "key" with the proper extension.

#!/bin/bash
# Dan Swain dan.t.swain at gmail.com 10/14/09

# Bash script to convert Keynote 2009 format to Keynote 2008.
#
# Many thanks to linux4research's blog post
# http://linux4research.blogspot.com/ (continued next line)
# (continued url) 2009/09/mac-keynote-2009-format.html
# for the .key to .zip step.

# input argument handling: DISABLED - I don't trust it enough
# not to erase your keynote file on accident...
# if -k is given as first argument, keep the original file
# and the output has "2008" added before .key
# otherwise the original file is overwritten (may be desirable
# because keynote files tend to be LARGE)
# if [ $# -ge 2 ] # note we may throw away extra arguments
# then
# if [ "$1" = "-k" ]
# then
# INPUT=$2
# KEEP=1
# else
# echo "Unknown argument $1, use -k to keep original file."
# exit
# fi
# else
# INPUT=$1
# KEEP=0
# fi

# safe input handling - need at least one argument
if [ $# -ne 1 ]
then
echo "Only one input argument allowed."
exit
fi
INPUT=$1
KEEP=1

# basename doesn't work for keynote files...
BASE=${INPUT%.key}
ZIPFILE=$BASE".zip"

if [ $KEEP -eq 1 ]
then
# output filename
OUTPUT=$BASE
OUTPUT=$OUTPUT" 2008.key"
# copy/rename to zipfile
echo "Copying $INPUT to $ZIPFILE, this may take a moment.."
cp $INPUT $ZIPFILE
echo "Done."
else
# output filename
OUTPUT=$INPUT
# rename to zipfile
mv $INPUT $ZIPFILE
fi

# unzip
echo "Unzipping $ZIPFILE."
unzip $ZIPFILE -d "$OUTPUT"
# erase the zipfile
echo "Erasing $ZIPFILE."
rm $ZIPFILE
# change the version number in the index file
echo "Converting version string to 2008."
INDEXAPXL=$OUTPUT/index.apxl
sed -i '' 's/version=\"[0-9]*/version=\"72007061400/g' "$INDEXAPXL"

25 comments:

Attila said...

hey Dan,

your post was super useful for me, saved me hell a lot of work!

Anonymous said...

Dan I'm a total noob here. What ap do I use to change the idex file?
Thanks Jamie

Dan said...

@Attila - You're welcome! It's great to hear that this was useful for someone.

@jambrew - You should be able to open index.apxl with TextEdit.

Anonymous said...

Extremely helpful. Thanks a million.
K

Anonymous said...

Once I change the code, how do I open up the keynote doc? Do I need to change the zip extension back to key?
Sorry, I'm new to this!

Dan said...

Rename the .key file to .zip and then unzip it - the result should be a folder. I.e. if your keynote file was MyPres.key, rename it to MyPres.zip and then unzip it and you should obtain a folder just called MyPres. You can edit the .apxl file, then rename the directory with a .key extension. If you don't want to overwrite the original file (safest, recommended), name it e.g. MyPres08.key

Jacob said...

Awesome, thanks a million for this. Saved me a bunch of trouble too.

Cheers!

Anonymous said...

Great post!!!

Jean-Marc Dormoy said...

Hi Dan,
thanks a lot, that was really helpful. I am working with 09, but I have to convert to 08 to be able to use the swf export feature.
It works well (I get my flash at the end of the process) but there is something strange when I open the keynote: my template is based on a red color, and on the keynote 08, slides are ... blue. The flash swf I get is red as the original. Do you have any idea of what might happen there?
Best,
JM

Dan said...

Hi JM,

I'm not sure I can be of much help :-/ I would guess there's a difference in the way the colors are stored in the two different versions of KeyNote, and that if you can figure out the difference, you could fix it manually. If you're ambitious, you could create a new file with the right background color and compare the apxl files. I'm looking at one of mine now and it has a bunch of lines looking like:

<sf:color xsi:type="sfa:calibrated-rgb-color-type" sfa:r="0" sfa:g="0" sfa:b="0" sfa:a="1"/>

OTOH, it should be relatively easy to change the background color of your template slide using "normal" methods. I think?

Good luck!
- Dan

Anonymous said...

Awesome post, got it working in a few minutes. Thanks a ton for this!

Keldon Rush said...
This comment has been removed by the author.
Keldon Rush said...

thank you SO much!!

Keldon Rush said...

Thank you SO much!!!

Erik Sellström said...

Thanx a bunch!

josh chambes said...

So so helpful. Thank you!

Vincent said...

Thanks, I googled for this and your answer popped up. I can open the keynote I wanted, which is great. Unfortunately, I get some warnings about missing files in the master slide. Anyway I can read the content, which is most important.

Thanks again!

Santiago said...

Dan,

thanks a lot, this post was awesome. Saved me a lot of problems. I can´t believe that googling for support on the Apple websites, really leads you to nothing and they just ignore the customers.
Thanks!

Anonymous said...

Hi,

Thank you for your help. It allowed me to create a Keynote 8 compatible version but when I try to open it in Keynote 8, the app crashes. Any idea what could be wrong?

Thanks again

Lingbo said...

Hey man, thanks so much - this saved me money and headache!! you rock.

Anonymous said...

Hi, I see that you give very useful advice and I have to give a lecture in a few days and I can´t open my Keynote document (Keynote 09). Is there something I coud do?
Greetings from Spain,
Rosa

Anonymous said...

Hey, I did the .zip thing and changed the key:version but when I try and open the folder as a .key, keynote says can't open file. Any ideas?

Julia said...

Just to bump this post up again...
Thanks for this work-around. Saved me a ton of time trying to coordinate an upgrade of iWork with a slow university IT department.

Todd said...

Absolutely amazing! Instructions were precise and easy to follow, even for someone with zero experience working with code. You are my hero, having saved me countless hours trying to reconstruct a presentation!

Darpa said...

Just used this Dan. You are awesome!!