2009/04/05
Export All OmniGraffle Files In A Folder To PDF

For my Master’s thesis I do a lot of the graphic work in OmniGraffle. But my thesis is in LaTeX, so all images need to be in pdf format. Fortunately OmniGraffle exports to PDF, and even better – it’s scriptable through AppleScript.

So I cooked up this small script that opens all OmniGraffle documents in a folder, and exports them to PDF files. The PDF files are named the same as the Graffle files, and will be saved in the same folder.

To use it, just load up Script Editor, paste, compile, and run. Of course, you could also save it to the AppleScripts folder so you can easily access it.

tell application "Finder"
set the theFolder to choose folder with
"Pick a folder containing the OmniGraffle files you want to export to PDF:"
set theList to every file of the theFolder whose
name extension is "graffle"
end tell

repeat with theFile in theList

set theOutFile to ((do shell script "basename \"" & (theFile) & "\"" & " .graffle") & ".pdf")
set theInFile to theFile as string

tell application "OmniGraffle Professional 5"
activate
open file (theInFile)

save front window in file theOutFile
close front window
end tell

end repeat

2 Responses to “Export All OmniGraffle Files In A Folder To PDF”

  1. Dirk 2010/04/22 at 07:28

    Thank you so much for sharing this master piece of code! ;) Your script saves me a lot of time!

Leave a Reply